diff --git a/OWASP DATASET CLEANED/BenchmarkTest00001.java b/OWASP DATASET CLEANED/BenchmarkTest00001.java deleted file mode 100644 index 34c82096ba8bc1b35e854522226ae1b18dff3ae4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00001.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00001") -public class BenchmarkTest00001 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00001", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00001.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00001")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00002.java b/OWASP DATASET CLEANED/BenchmarkTest00002.java deleted file mode 100644 index b31b6a33439aa4039fdd195a033f7f849eb26ea4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00002.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00002") -public class BenchmarkTest00002 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00002", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00002.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00002")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00003.java b/OWASP DATASET CLEANED/BenchmarkTest00003.java deleted file mode 100644 index 501535c874b67daac6e9d139c8518dbcb02cef12..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00003.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00003") -public class BenchmarkTest00003 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00003", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-00/BenchmarkTest00003.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00003")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = param; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00004.java b/OWASP DATASET CLEANED/BenchmarkTest00004.java deleted file mode 100644 index beaa3b25c742434e54f55a41927c1b713a32d32d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00004.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00004") -public class BenchmarkTest00004 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00004", "color"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-00/BenchmarkTest00004.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00004")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(param, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(param) - + "' with value: '10340' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00005.java b/OWASP DATASET CLEANED/BenchmarkTest00005.java deleted file mode 100644 index 64ea4187ef3155544bbafed5ff2b2c500a20e8f2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00005.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00005") -public class BenchmarkTest00005 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00005") != null) { - param = request.getHeader("BenchmarkTest00005"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = param; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00006.java b/OWASP DATASET CLEANED/BenchmarkTest00006.java deleted file mode 100644 index 2359c9ba862113eb91cf1186df6cf38c778e4187..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00006.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00006") -public class BenchmarkTest00006 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00006") != null) { - param = request.getHeader("BenchmarkTest00006"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + param); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00007.java b/OWASP DATASET CLEANED/BenchmarkTest00007.java deleted file mode 100644 index d1d180aa9f6c2b30f93c1c6b2dc27361eaaea7c9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00007.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00007") -public class BenchmarkTest00007 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00007") != null) { - param = request.getHeader("BenchmarkTest00007"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {param}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00008.java b/OWASP DATASET CLEANED/BenchmarkTest00008.java deleted file mode 100644 index 3d2710eec4492292c190f7e8021c30a10496d344..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00008.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00008") -public class BenchmarkTest00008 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00008") != null) { - param = request.getHeader("BenchmarkTest00008"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String sql = "{call " + param + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00009.java b/OWASP DATASET CLEANED/BenchmarkTest00009.java deleted file mode 100644 index abe18a4e5721040eec4af6da80b9426b38bab1c0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00009.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00009") -public class BenchmarkTest00009 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = param; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00010.java b/OWASP DATASET CLEANED/BenchmarkTest00010.java deleted file mode 100644 index 2a083966ec9bb4f97e61b6fd4957df646f7d6bd9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00010.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00010") -public class BenchmarkTest00010 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00011.java b/OWASP DATASET CLEANED/BenchmarkTest00011.java deleted file mode 100644 index cfda6fb0fa0f96d9e5586709122f15abfe0f8f94..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00011.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00011") -public class BenchmarkTest00011 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00011"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - java.io.File fileTarget = new java.io.File(param, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00012.java b/OWASP DATASET CLEANED/BenchmarkTest00012.java deleted file mode 100644 index 5be39e80f906e2bdd567d3798ee2f09cff1904fa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00012.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00012") -public class BenchmarkTest00012 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00012"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + param + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00013.java b/OWASP DATASET CLEANED/BenchmarkTest00013.java deleted file mode 100644 index 0073b0e90d2f0871cbef7b879b6fe24089f725b1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00013.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00013") -public class BenchmarkTest00013 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, param, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00014.java b/OWASP DATASET CLEANED/BenchmarkTest00014.java deleted file mode 100644 index 2038ab9f06f1a86b200df9ac1ffb5d4b0022c27c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00014.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00014") -public class BenchmarkTest00014 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(param, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00015.java b/OWASP DATASET CLEANED/BenchmarkTest00015.java deleted file mode 100644 index 4f4f57ff5d8acb3d1d9e8d16fbe7eede8e27de6d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00015.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00015") -public class BenchmarkTest00015 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00015"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + param); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00016.java b/OWASP DATASET CLEANED/BenchmarkTest00016.java deleted file mode 100644 index cfa38dee89f68e1e91def05eee8acddd3cdf3bb5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00016.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00016") -public class BenchmarkTest00016 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00016"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00017.java b/OWASP DATASET CLEANED/BenchmarkTest00017.java deleted file mode 100644 index b022e9160cf5ec4cb20bcace8b95ad3ce85e5af5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00017.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00017") -public class BenchmarkTest00017 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00017"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + param); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00018.java b/OWASP DATASET CLEANED/BenchmarkTest00018.java deleted file mode 100644 index df9dae2ab50bd0634b0c224b31bdb8a43b97b29b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00018.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00018") -public class BenchmarkTest00018 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00018"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + param + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00019.java b/OWASP DATASET CLEANED/BenchmarkTest00019.java deleted file mode 100644 index f3fddb73d17783734e2055015d63ffdfe731abc6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00019.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00019") -public class BenchmarkTest00019 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - java.io.InputStream param = request.getInputStream(); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = param; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00020.java b/OWASP DATASET CLEANED/BenchmarkTest00020.java deleted file mode 100644 index 33266ef3e6a21f85fba7b57fa2ed2cce87b7a3bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00020.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00020") -public class BenchmarkTest00020 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00020"); - if (param == null) param = ""; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = param; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00021.java b/OWASP DATASET CLEANED/BenchmarkTest00021.java deleted file mode 100644 index 0b469a363f74833345e5db3aa1fb0f910b9fe871..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00021.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00021") -public class BenchmarkTest00021 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00021"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + param + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00022.java b/OWASP DATASET CLEANED/BenchmarkTest00022.java deleted file mode 100644 index b9c8ae630e9bac8b664a2dd84ab1b0118ec38181..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00022.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00022") -public class BenchmarkTest00022 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00022"); - if (param == null) param = ""; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = param; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00023.java b/OWASP DATASET CLEANED/BenchmarkTest00023.java deleted file mode 100644 index a26bb3eb4418ac3669e12e205ec9945b6d1ba021..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00023.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00023") -public class BenchmarkTest00023 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00023"); - if (param == null) param = ""; - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00024.java b/OWASP DATASET CLEANED/BenchmarkTest00024.java deleted file mode 100644 index a43678bea54ad1fb2417c4b088d17615f203b72f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00024.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00024") -public class BenchmarkTest00024 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00024"); - if (param == null) param = ""; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + param + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00025.java b/OWASP DATASET CLEANED/BenchmarkTest00025.java deleted file mode 100644 index 051a1c7ba6fabd10c3158513afb2fb6135faa790..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00025.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00025") -public class BenchmarkTest00025 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00025"); - if (param == null) param = ""; - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + param + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00026.java b/OWASP DATASET CLEANED/BenchmarkTest00026.java deleted file mode 100644 index dcdda026919e9b7c4ff656c1f22ac4e78264feb4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00026.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00026") -public class BenchmarkTest00026 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00026"); - if (param == null) param = ""; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + param + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00027.java b/OWASP DATASET CLEANED/BenchmarkTest00027.java deleted file mode 100644 index 27344a048a99114f397b0fd2f3840540d4590ec2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00027.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00027") -public class BenchmarkTest00027 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00027"); - if (param == null) param = ""; - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + param + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00028.java b/OWASP DATASET CLEANED/BenchmarkTest00028.java deleted file mode 100644 index 265945d77ed0de865d42b2502b731fde9a1f2a09..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00028.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00028") -public class BenchmarkTest00028 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00028"); - if (values != null) param = values[0]; - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00029.java b/OWASP DATASET CLEANED/BenchmarkTest00029.java deleted file mode 100644 index f0ea91e0c2712c141e3eb22632597f8f8dd9fa43..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00029.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00029") -public class BenchmarkTest00029 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00029"); - if (values != null) param = values[0]; - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = param; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00030.java b/OWASP DATASET CLEANED/BenchmarkTest00030.java deleted file mode 100644 index 5077e0d9d7118f3bd354ed558a4fba2fbf1a6b0c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00030.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00030") -public class BenchmarkTest00030 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00030"); - if (values != null) param = values[0]; - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(param, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00031.java b/OWASP DATASET CLEANED/BenchmarkTest00031.java deleted file mode 100644 index bfc2971c714a4a4fd9b064339087d1ad54936e2b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00031.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00031") -public class BenchmarkTest00031 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00031"); - if (values != null) param = values[0]; - } - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", param); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(param) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00032.java b/OWASP DATASET CLEANED/BenchmarkTest00032.java deleted file mode 100644 index 2f829c2918e4e31128ae2c9110d7b4997c832eb4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00032.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00032") -public class BenchmarkTest00032 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00032"); - if (values != null) param = values[0]; - } - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + param + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00033.java b/OWASP DATASET CLEANED/BenchmarkTest00033.java deleted file mode 100644 index bcfa5d1d4f3d8c82733adca517a520ce76207154..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00033.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00033") -public class BenchmarkTest00033 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00033"); - if (values != null) param = values[0]; - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + param + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00034.java b/OWASP DATASET CLEANED/BenchmarkTest00034.java deleted file mode 100644 index a4967179a23d14d0a1d277c7f083654939fc0eda..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00034.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00034") -public class BenchmarkTest00034 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00034"); - if (values != null) param = values[0]; - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + param + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00035.java b/OWASP DATASET CLEANED/BenchmarkTest00035.java deleted file mode 100644 index 59328d36a9dea39aa9ee7f19f35c150b20d82d78..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00035.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00035") -public class BenchmarkTest00035 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00035")) { - param = name; - flag = false; - } - } - } - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = param; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00036.java b/OWASP DATASET CLEANED/BenchmarkTest00036.java deleted file mode 100644 index 2b6c4576230b373fb0d184d949412f856dafd5aa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00036.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00036") -public class BenchmarkTest00036 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00036")) { - param = name; - flag = false; - } - } - } - } - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (param != null) { - length = param.length(); - response.getWriter().write(param.toCharArray(), 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00037.java b/OWASP DATASET CLEANED/BenchmarkTest00037.java deleted file mode 100644 index e3babd8a10b460c3cbec769c3db9a7ddb6138ab3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00037.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00037") -public class BenchmarkTest00037 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00037")) { - param = name; - flag = false; - } - } - } - } - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + param + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00038.java b/OWASP DATASET CLEANED/BenchmarkTest00038.java deleted file mode 100644 index afd267f13c7200efbe08c9df16c2bcadce23f751..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00038.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00038") -public class BenchmarkTest00038 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00038")) { - param = name; - flag = false; - } - } - } - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + param + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00039.java b/OWASP DATASET CLEANED/BenchmarkTest00039.java deleted file mode 100644 index d4fce4685bd9cc44981befeaa0473c0fd4dc513f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00039.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00039") -public class BenchmarkTest00039 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00039")) { - param = name; - flag = false; - } - } - } - } - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + param + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00040.java b/OWASP DATASET CLEANED/BenchmarkTest00040.java deleted file mode 100644 index 71bc125e2c9ca66cc4399f25199eda74a81459c7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00040.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00040") -public class BenchmarkTest00040 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00040"); - if (param == null) param = ""; - - java.io.File fileTarget = new java.io.File(param); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00041.java b/OWASP DATASET CLEANED/BenchmarkTest00041.java deleted file mode 100644 index 98e58d1dce35f599b8edc0a3717986808431a324..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00041.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00041") -public class BenchmarkTest00041 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00041"); - if (param == null) param = ""; - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (param != null) { - length = param.length(); - response.getWriter().write(param, 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00042.java b/OWASP DATASET CLEANED/BenchmarkTest00042.java deleted file mode 100644 index dfa3e8ff397f92d068c48b5718a2f7292f28e603..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00042.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00042") -public class BenchmarkTest00042 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00042"); - if (param == null) param = ""; - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00043.java b/OWASP DATASET CLEANED/BenchmarkTest00043.java deleted file mode 100644 index e20d25a567a6a3ccdfd83999ce932e0c20b75dbe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00043.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00043") -public class BenchmarkTest00043 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00043"); - if (param == null) param = ""; - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + param + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00044.java b/OWASP DATASET CLEANED/BenchmarkTest00044.java deleted file mode 100644 index 58d299d61993e228b8626c872e40d7fdb84df3b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00044.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00044") -public class BenchmarkTest00044 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00044"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + param + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00045.java b/OWASP DATASET CLEANED/BenchmarkTest00045.java deleted file mode 100644 index f425d61a1e38d6eafdac907103cf5bd8b89d940e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00045.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00045") -public class BenchmarkTest00045 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00045"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + - // param).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00046.java b/OWASP DATASET CLEANED/BenchmarkTest00046.java deleted file mode 100644 index 4956e4a9b52f7daff93c098dbfde0d419efe9dfc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00046.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00046") -public class BenchmarkTest00046 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00046"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = param; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00047.java b/OWASP DATASET CLEANED/BenchmarkTest00047.java deleted file mode 100644 index 59f12dc1788df96210819a3eb0b20ba3ee39e473..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00047.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00047") -public class BenchmarkTest00047 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00047" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00047" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00047" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(param, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00048.java b/OWASP DATASET CLEANED/BenchmarkTest00048.java deleted file mode 100644 index b528f008ecd1696ef8f2ac78dc159760b883e09e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00048.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00048") -public class BenchmarkTest00048 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00048" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00048" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00048" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(param.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00049.java b/OWASP DATASET CLEANED/BenchmarkTest00049.java deleted file mode 100644 index c3b0e43c70f41948dc6a3e7de63a0298cd713c27..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00049.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00049") -public class BenchmarkTest00049 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00049" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00049" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00049" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + param); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00050.java b/OWASP DATASET CLEANED/BenchmarkTest00050.java deleted file mode 100644 index 2f74b7bb3415842f2fd03a365c4c99a2556a8284..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00050.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00050") -public class BenchmarkTest00050 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00050"); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = param; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00051.java b/OWASP DATASET CLEANED/BenchmarkTest00051.java deleted file mode 100644 index b9ec7bb47c45ef4fc84b2e7bdd5e29eabae6ac69..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00051.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00051") -public class BenchmarkTest00051 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00051"); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + param}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00052.java b/OWASP DATASET CLEANED/BenchmarkTest00052.java deleted file mode 100644 index caa0f146155e5ae5e6fa1a55a90716beda4d9e94..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00052.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00052") -public class BenchmarkTest00052 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - // some code - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00052"); - - String sql = "{call " + param + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00053.java b/OWASP DATASET CLEANED/BenchmarkTest00053.java deleted file mode 100644 index d2b0b30ed13a49f645ef11cfc9b79d7a3bcc97e4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00053.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00053") -public class BenchmarkTest00053 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00053", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-00/BenchmarkTest00053.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00053")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00054.java b/OWASP DATASET CLEANED/BenchmarkTest00054.java deleted file mode 100644 index f7686414626be33f222cd1965aa7074bf61bc13b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00054.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00054") -public class BenchmarkTest00054 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00054", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-00/BenchmarkTest00054.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00054")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00055.java b/OWASP DATASET CLEANED/BenchmarkTest00055.java deleted file mode 100644 index 23bd9f8d49c8216cee021ea44bd3fcec0d18a5c1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00055.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00055") -public class BenchmarkTest00055 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00055", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-00/BenchmarkTest00055.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00055")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00056.java b/OWASP DATASET CLEANED/BenchmarkTest00056.java deleted file mode 100644 index 29390d61909e51b1759fdbc6e67bcee02440f67d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00056.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00056") -public class BenchmarkTest00056 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00056", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-00/BenchmarkTest00056.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00056")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00057.java b/OWASP DATASET CLEANED/BenchmarkTest00057.java deleted file mode 100644 index 4ef862d5aea7e09b735da54ec7c99b611b201263..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00057.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00057") -public class BenchmarkTest00057 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00057", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-00/BenchmarkTest00057.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00057")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00058.java b/OWASP DATASET CLEANED/BenchmarkTest00058.java deleted file mode 100644 index 7d03df2bafb543c77a0b738f522f8c036514bd3b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00058.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00058") -public class BenchmarkTest00058 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00058", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-00/BenchmarkTest00058.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00058")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00059.java b/OWASP DATASET CLEANED/BenchmarkTest00059.java deleted file mode 100644 index 2a138ea63b14d662f8ae0d8b3bca0d548c80e710..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00059.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00059") -public class BenchmarkTest00059 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00059", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-00/BenchmarkTest00059.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00059")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - StringBuilder sbxyz22532 = new StringBuilder(param); - String bar = sbxyz22532.append("_SafeStuff").toString(); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00060.java b/OWASP DATASET CLEANED/BenchmarkTest00060.java deleted file mode 100644 index a64f933d3e74a454dbaad3cfabc389bcfa0aee25..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00060.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00060") -public class BenchmarkTest00060 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00060", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00060.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00060")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00061.java b/OWASP DATASET CLEANED/BenchmarkTest00061.java deleted file mode 100644 index e0d2e0036902f16a24ed8b68ace8aeca63a25fc2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00061.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00061") -public class BenchmarkTest00061 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00061", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00061.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00061")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00062.java b/OWASP DATASET CLEANED/BenchmarkTest00062.java deleted file mode 100644 index 44f0ea70b7727b314804f7765b44dddeddad5632..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00062.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00062") -public class BenchmarkTest00062 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00062", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00062.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00062")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "safe!"; - java.util.HashMap map77232 = new java.util.HashMap(); - map77232.put("keyA-77232", "a-Value"); // put some stuff in the collection - map77232.put("keyB-77232", param); // put it in a collection - map77232.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map77232.get("keyB-77232"); // get it back out - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00063.java b/OWASP DATASET CLEANED/BenchmarkTest00063.java deleted file mode 100644 index 3e9550a7ea3ecaf69b2efeac11adafb936fefcb8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00063.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00063") -public class BenchmarkTest00063 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00063", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00063.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00063")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00064.java b/OWASP DATASET CLEANED/BenchmarkTest00064.java deleted file mode 100644 index 79a829e3b4d877a7b17d5dc58b2873f4f352a0ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00064.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00064") -public class BenchmarkTest00064 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00064", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00064.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00064")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00065.java b/OWASP DATASET CLEANED/BenchmarkTest00065.java deleted file mode 100644 index 483faac90e3d5986f71782ed8941132f556da1e2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00065.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00065") -public class BenchmarkTest00065 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00065", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00065.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00065")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00066.java b/OWASP DATASET CLEANED/BenchmarkTest00066.java deleted file mode 100644 index 81f632e6467ec6db014c11a64ae928acf49250fb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00066.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00066") -public class BenchmarkTest00066 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00066", "anything"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00066.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00066")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00067.java b/OWASP DATASET CLEANED/BenchmarkTest00067.java deleted file mode 100644 index 625cb93271629698cad0963f5bbcf513775be5c9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00067.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00067") -public class BenchmarkTest00067 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00067", "anything"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00067.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00067")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - // Chain a bunch of propagators in sequence - String a71153 = param; // assign - StringBuilder b71153 = new StringBuilder(a71153); // stick in stringbuilder - b71153.append(" SafeStuff"); // append some safe content - b71153.replace( - b71153.length() - "Chars".length(), - b71153.length(), - "Chars"); // replace some of the end content - java.util.HashMap map71153 = new java.util.HashMap(); - map71153.put("key71153", b71153.toString()); // put in a collection - String c71153 = (String) map71153.get("key71153"); // get it back out - String d71153 = c71153.substring(0, c71153.length() - 1); // extract most of it - String e71153 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d71153.getBytes()))); // B64 encode and decode it - String f71153 = e71153.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g71153 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g71153); // reflection - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00068.java b/OWASP DATASET CLEANED/BenchmarkTest00068.java deleted file mode 100644 index a767d4fed3ed52376f115f8f46666d6685de1ae2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00068.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00068") -public class BenchmarkTest00068 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00068", "anything"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00068.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00068")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00069.java b/OWASP DATASET CLEANED/BenchmarkTest00069.java deleted file mode 100644 index 508d372969bc7c2886a63e4dfe343ee6d9f292a4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00069.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00069") -public class BenchmarkTest00069 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00069", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-00/BenchmarkTest00069.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00069")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00070.java b/OWASP DATASET CLEANED/BenchmarkTest00070.java deleted file mode 100644 index 594071e2b8ee97034f17f444fdf6c4d1f8f8da90..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00070.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00070") -public class BenchmarkTest00070 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00070", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-00/BenchmarkTest00070.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00070")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00071.java b/OWASP DATASET CLEANED/BenchmarkTest00071.java deleted file mode 100644 index a2400b31c9f01d6a93f2694596f78b5145255bcb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00071.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00071") -public class BenchmarkTest00071 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00071", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-00/BenchmarkTest00071.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00071")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00072.java b/OWASP DATASET CLEANED/BenchmarkTest00072.java deleted file mode 100644 index afa3284c5724b21f852d8e1852e4c98b237938eb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00072.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00072") -public class BenchmarkTest00072 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00072", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-00/BenchmarkTest00072.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00072")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00073.java b/OWASP DATASET CLEANED/BenchmarkTest00073.java deleted file mode 100644 index 6aa740440aa0c47984fe3a82efb5ee5d912814c1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00073.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00073") -public class BenchmarkTest00073 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00073", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-00/BenchmarkTest00073.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00073")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00074.java b/OWASP DATASET CLEANED/BenchmarkTest00074.java deleted file mode 100644 index b1cc4ddfc2bb4aa03c56a8526113afa0cebaef40..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00074.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00074") -public class BenchmarkTest00074 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00074", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-00/BenchmarkTest00074.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00074")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "safe!"; - java.util.HashMap map98790 = new java.util.HashMap(); - map98790.put("keyA-98790", "a-Value"); // put some stuff in the collection - map98790.put("keyB-98790", param); // put it in a collection - map98790.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map98790.get("keyB-98790"); // get it back out - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00075.java b/OWASP DATASET CLEANED/BenchmarkTest00075.java deleted file mode 100644 index 5722b0bc4c1c5fb4e21e1e647b0299823029d327..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00075.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00075") -public class BenchmarkTest00075 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00075", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-00/BenchmarkTest00075.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00075")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00076.java b/OWASP DATASET CLEANED/BenchmarkTest00076.java deleted file mode 100644 index 3b38ebb83c80abcb4c441c92e151e4179a1bf9e4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00076.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00076") -public class BenchmarkTest00076 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00076", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-00/BenchmarkTest00076.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00076")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00077.java b/OWASP DATASET CLEANED/BenchmarkTest00077.java deleted file mode 100644 index d929ba69349ccda063630b5fac03ea3143b9fe97..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00077.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00077") -public class BenchmarkTest00077 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00077", "ECHOOO"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-00/BenchmarkTest00077.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00077")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00078.java b/OWASP DATASET CLEANED/BenchmarkTest00078.java deleted file mode 100644 index 5773c9d2a4987fae84bdf6bee024f91a8f716675..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00078.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00078") -public class BenchmarkTest00078 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00078", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00078.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00078")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00079.java b/OWASP DATASET CLEANED/BenchmarkTest00079.java deleted file mode 100644 index 0cc7c196d807ae7f1d699c7c410e1b9223cf9937..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00079.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00079") -public class BenchmarkTest00079 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00079", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00079.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00079")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "safe!"; - java.util.HashMap map18384 = new java.util.HashMap(); - map18384.put("keyA-18384", "a-Value"); // put some stuff in the collection - map18384.put("keyB-18384", param); // put it in a collection - map18384.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map18384.get("keyB-18384"); // get it back out - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00080.java b/OWASP DATASET CLEANED/BenchmarkTest00080.java deleted file mode 100644 index b39fc2434f8515ba5cd98336b6683bcf7b6be2cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00080.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00080") -public class BenchmarkTest00080 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00080", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00080.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00080")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00081.java b/OWASP DATASET CLEANED/BenchmarkTest00081.java deleted file mode 100644 index a0b486ee756b7a5dcfafa8b9630f33e6e35b11bd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00081.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00081") -public class BenchmarkTest00081 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00081", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00081.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00081")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00082.java b/OWASP DATASET CLEANED/BenchmarkTest00082.java deleted file mode 100644 index c0de01c39c2186f69a8bb8919d2afa9845df2943..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00082.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00082") -public class BenchmarkTest00082 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00082", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00082.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00082")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - StringBuilder sbxyz58640 = new StringBuilder(param); - String bar = sbxyz58640.append("_SafeStuff").toString(); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00083.java b/OWASP DATASET CLEANED/BenchmarkTest00083.java deleted file mode 100644 index 6f509bf5deedf3fc8af646d0a4de945591964ecc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00083.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00083") -public class BenchmarkTest00083 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00083", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00083.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00083")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00084.java b/OWASP DATASET CLEANED/BenchmarkTest00084.java deleted file mode 100644 index 03c3eb0cb3e15083776cd54cf287cdda6ddb389e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00084.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00084") -public class BenchmarkTest00084 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00084", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00084.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00084")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00085.java b/OWASP DATASET CLEANED/BenchmarkTest00085.java deleted file mode 100644 index 3cd977db9ea79ebc8e87b7dfb1a31c2c5147698d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00085.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00085") -public class BenchmarkTest00085 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00085", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00085.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00085")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "safe!"; - java.util.HashMap map43974 = new java.util.HashMap(); - map43974.put("keyA-43974", "a-Value"); // put some stuff in the collection - map43974.put("keyB-43974", param); // put it in a collection - map43974.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map43974.get("keyB-43974"); // get it back out - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00086.java b/OWASP DATASET CLEANED/BenchmarkTest00086.java deleted file mode 100644 index cd31ec9742351aacdb7b4101415abf2481f2f7da..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00086.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00086") -public class BenchmarkTest00086 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00086", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00086.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00086")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00087.java b/OWASP DATASET CLEANED/BenchmarkTest00087.java deleted file mode 100644 index 460086f96cb7a49e669f0be55c7dbac94ffdccd2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00087.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00087") -public class BenchmarkTest00087 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00087", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/securecookie-00/BenchmarkTest00087.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00087")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00088.java b/OWASP DATASET CLEANED/BenchmarkTest00088.java deleted file mode 100644 index 4da339103388e400f33b02278a42aaba19331438..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00088.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00088") -public class BenchmarkTest00088 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00088", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/securecookie-00/BenchmarkTest00088.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00088")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00089.java b/OWASP DATASET CLEANED/BenchmarkTest00089.java deleted file mode 100644 index ff09d01f11e40222da0e54f4503d1f828406bd8c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00089.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00089") -public class BenchmarkTest00089 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00089", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/securecookie-00/BenchmarkTest00089.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00089")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00090.java b/OWASP DATASET CLEANED/BenchmarkTest00090.java deleted file mode 100644 index 6f045cb9f0c939eaff680f52f58f1c07d734bf27..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00090.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00090") -public class BenchmarkTest00090 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00090", "ls"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-00/BenchmarkTest00090.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00090")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00091.java b/OWASP DATASET CLEANED/BenchmarkTest00091.java deleted file mode 100644 index 4a983d3ca684def58aa8f7e6c4731b81d36b805b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00091.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00091") -public class BenchmarkTest00091 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00091", "FOO%3Decho+Injection"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-00/BenchmarkTest00091.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00091")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = param; - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00092.java b/OWASP DATASET CLEANED/BenchmarkTest00092.java deleted file mode 100644 index 9421950e4329beb281ffa87fdb6f340d5abc2f6e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00092.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00092") -public class BenchmarkTest00092 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00092", "FOO%3Decho+Injection"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-00/BenchmarkTest00092.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00092")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00093.java b/OWASP DATASET CLEANED/BenchmarkTest00093.java deleted file mode 100644 index 56372b8c82c29db48b1c24b1744d57c12e5ae18d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00093.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00093") -public class BenchmarkTest00093 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00093", "ls"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-00/BenchmarkTest00093.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00093")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00094.java b/OWASP DATASET CLEANED/BenchmarkTest00094.java deleted file mode 100644 index f6e2b83b29bb981a37c373e0fb124c7a4766600d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00094.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00094") -public class BenchmarkTest00094 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00094", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00094.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00094")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "safe!"; - java.util.HashMap map52993 = new java.util.HashMap(); - map52993.put("keyA-52993", "a_Value"); // put some stuff in the collection - map52993.put("keyB-52993", param); // put it in a collection - map52993.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map52993.get("keyB-52993"); // get it back out - bar = (String) map52993.get("keyA-52993"); // get safe value back out - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00095.java b/OWASP DATASET CLEANED/BenchmarkTest00095.java deleted file mode 100644 index d817be4a47601ab42c9dbbd91024b71b0da210dc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00095.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00095") -public class BenchmarkTest00095 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00095", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00095.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00095")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "safe!"; - java.util.HashMap map45268 = new java.util.HashMap(); - map45268.put("keyA-45268", "a-Value"); // put some stuff in the collection - map45268.put("keyB-45268", param); // put it in a collection - map45268.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map45268.get("keyB-45268"); // get it back out - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00096.java b/OWASP DATASET CLEANED/BenchmarkTest00096.java deleted file mode 100644 index 53537aea13157035ce1c0cd6813b04f6949bb448..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00096.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00096") -public class BenchmarkTest00096 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00096", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-00/BenchmarkTest00096.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00096")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00097.java b/OWASP DATASET CLEANED/BenchmarkTest00097.java deleted file mode 100644 index 10fe45f85c739e9305381210932414a704f179fa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00097.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00097") -public class BenchmarkTest00097 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00097", "color"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-00/BenchmarkTest00097.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00097")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00098.java b/OWASP DATASET CLEANED/BenchmarkTest00098.java deleted file mode 100644 index daeadc40ef3df37c103a60cff02b8db8ea78a89f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00098.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00098") -public class BenchmarkTest00098 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00098", "my_user_id"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-00/BenchmarkTest00098.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00098")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00099.java b/OWASP DATASET CLEANED/BenchmarkTest00099.java deleted file mode 100644 index bc8c41f1403f63976a0d68d05c69decd252bceaf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00099.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00099") -public class BenchmarkTest00099 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00099", "my_userid"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-00/BenchmarkTest00099.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00099")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00100.java b/OWASP DATASET CLEANED/BenchmarkTest00100.java deleted file mode 100644 index 9e8349062c12465de8e5210fa8fdafc45505481e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00100.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00100") -public class BenchmarkTest00100 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00100", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00100.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00100")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "safe!"; - java.util.HashMap map72344 = new java.util.HashMap(); - map72344.put("keyA-72344", "a-Value"); // put some stuff in the collection - map72344.put("keyB-72344", param); // put it in a collection - map72344.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map72344.get("keyB-72344"); // get it back out - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00101.java b/OWASP DATASET CLEANED/BenchmarkTest00101.java deleted file mode 100644 index 3ed4c9a6a4407a50237b7804b5c4b807622d425e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00101.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00101") -public class BenchmarkTest00101 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00101", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00101.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00101")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00102.java b/OWASP DATASET CLEANED/BenchmarkTest00102.java deleted file mode 100644 index f1b552dd7f75e00afd4ba141aefc5d51d40bcf64..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00102.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00102") -public class BenchmarkTest00102 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00102", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00102.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00102")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00103.java b/OWASP DATASET CLEANED/BenchmarkTest00103.java deleted file mode 100644 index d3845ed61d5adfb471d8f1a044e21bc79f78902d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00103.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00103") -public class BenchmarkTest00103 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00103", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00103.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00103")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00104.java b/OWASP DATASET CLEANED/BenchmarkTest00104.java deleted file mode 100644 index 2794ec8e110f0ed92c90a181e9c10d36fbd3117c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00104.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00104") -public class BenchmarkTest00104 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00104", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00104.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00104")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00105.java b/OWASP DATASET CLEANED/BenchmarkTest00105.java deleted file mode 100644 index 6d5d0f5b5f6bf5b17d986bdbba9ef04dfe31fad6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00105.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00105") -public class BenchmarkTest00105 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00105", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00105.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00105")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00106.java b/OWASP DATASET CLEANED/BenchmarkTest00106.java deleted file mode 100644 index e844eb8d45662d9925c2b4fdd8ebfc41cff8a131..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00106.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00106") -public class BenchmarkTest00106 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00106", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00106.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00106")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00107.java b/OWASP DATASET CLEANED/BenchmarkTest00107.java deleted file mode 100644 index 37994ba34533d823c0a09849a678fa5e70ebafbd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00107.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00107") -public class BenchmarkTest00107 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00107", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00107.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00107")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - // Chain a bunch of propagators in sequence - String a18521 = param; // assign - StringBuilder b18521 = new StringBuilder(a18521); // stick in stringbuilder - b18521.append(" SafeStuff"); // append some safe content - b18521.replace( - b18521.length() - "Chars".length(), - b18521.length(), - "Chars"); // replace some of the end content - java.util.HashMap map18521 = new java.util.HashMap(); - map18521.put("key18521", b18521.toString()); // put in a collection - String c18521 = (String) map18521.get("key18521"); // get it back out - String d18521 = c18521.substring(0, c18521.length() - 1); // extract most of it - String e18521 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d18521.getBytes()))); // B64 encode and decode it - String f18521 = e18521.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g18521 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g18521); // reflection - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00108.java b/OWASP DATASET CLEANED/BenchmarkTest00108.java deleted file mode 100644 index 936abe85726edf31d63edce6a8222a9bb066bbdb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00108.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00108") -public class BenchmarkTest00108 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00108", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00108.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00108")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00109.java b/OWASP DATASET CLEANED/BenchmarkTest00109.java deleted file mode 100644 index 2816bc4edc4c20d2ae806ce4cb1a35282d4bf8bd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00109.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00109") -public class BenchmarkTest00109 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00109", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00109.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00109")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00110.java b/OWASP DATASET CLEANED/BenchmarkTest00110.java deleted file mode 100644 index 3bb8262098e91b97e4081b89e2da777feaa3c1e1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00110.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00110") -public class BenchmarkTest00110 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00110", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00110.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00110")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - // Chain a bunch of propagators in sequence - String a69840 = param; // assign - StringBuilder b69840 = new StringBuilder(a69840); // stick in stringbuilder - b69840.append(" SafeStuff"); // append some safe content - b69840.replace( - b69840.length() - "Chars".length(), - b69840.length(), - "Chars"); // replace some of the end content - java.util.HashMap map69840 = new java.util.HashMap(); - map69840.put("key69840", b69840.toString()); // put in a collection - String c69840 = (String) map69840.get("key69840"); // get it back out - String d69840 = c69840.substring(0, c69840.length() - 1); // extract most of it - String e69840 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d69840.getBytes()))); // B64 encode and decode it - String f69840 = e69840.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g69840 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g69840); // reflection - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00111.java b/OWASP DATASET CLEANED/BenchmarkTest00111.java deleted file mode 100644 index 70ff23ca686b36ac1cfe826ed6894a6f44d4a9b6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00111.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00111") -public class BenchmarkTest00111 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00111", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00111.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00111")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00112.java b/OWASP DATASET CLEANED/BenchmarkTest00112.java deleted file mode 100644 index fdef001896579a783bfa3efd01526f686ed48536..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00112.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00112") -public class BenchmarkTest00112 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00112", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00112.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00112")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00113.java b/OWASP DATASET CLEANED/BenchmarkTest00113.java deleted file mode 100644 index fb9bc79c7cf94b7abdd0e90914efc139d921bcb4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00113.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00113") -public class BenchmarkTest00113 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00113", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00113.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00113")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "safe!"; - java.util.HashMap map21657 = new java.util.HashMap(); - map21657.put("keyA-21657", "a_Value"); // put some stuff in the collection - map21657.put("keyB-21657", param); // put it in a collection - map21657.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map21657.get("keyB-21657"); // get it back out - bar = (String) map21657.get("keyA-21657"); // get safe value back out - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00114.java b/OWASP DATASET CLEANED/BenchmarkTest00114.java deleted file mode 100644 index 996189bce35becaf16125afd788d60ca98511afb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00114.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00114") -public class BenchmarkTest00114 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00114", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00114.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00114")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00115.java b/OWASP DATASET CLEANED/BenchmarkTest00115.java deleted file mode 100644 index 677548bb40a0ff883bc5c8406ec9683f2f394876..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00115.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00115") -public class BenchmarkTest00115 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00115", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-00/BenchmarkTest00115.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00115")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "safe!"; - java.util.HashMap map11928 = new java.util.HashMap(); - map11928.put("keyA-11928", "a-Value"); // put some stuff in the collection - map11928.put("keyB-11928", param); // put it in a collection - map11928.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map11928.get("keyB-11928"); // get it back out - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00116.java b/OWASP DATASET CLEANED/BenchmarkTest00116.java deleted file mode 100644 index 6ffcc0b757ded030135c28c62b2c170f50f385dc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00116.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest00116") -public class BenchmarkTest00116 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00116", "2222"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/xpathi-00/BenchmarkTest00116.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00116")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = "safe!"; - java.util.HashMap map51005 = new java.util.HashMap(); - map51005.put("keyA-51005", "a_Value"); // put some stuff in the collection - map51005.put("keyB-51005", param); // put it in a collection - map51005.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map51005.get("keyB-51005"); // get it back out - bar = (String) map51005.get("keyA-51005"); // get safe value back out - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00117.java b/OWASP DATASET CLEANED/BenchmarkTest00117.java deleted file mode 100644 index 9829ccc8a143bc7aeae963d225db10ff42b3db9b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00117.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest00117") -public class BenchmarkTest00117 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00117", "2222"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/xpathi-00/BenchmarkTest00117.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00117")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00118.java b/OWASP DATASET CLEANED/BenchmarkTest00118.java deleted file mode 100644 index c768c2a1c85d86647503995eedb376e6a22840a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00118.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest00118") -public class BenchmarkTest00118 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00118", "2222"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/xpathi-00/BenchmarkTest00118.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00118")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00119.java b/OWASP DATASET CLEANED/BenchmarkTest00119.java deleted file mode 100644 index ad33562eebfc7712b1c2d68ed198ff4f4d527850..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00119.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00119") -public class BenchmarkTest00119 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00119") != null) { - param = request.getHeader("BenchmarkTest00119"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a8142 = param; // assign - StringBuilder b8142 = new StringBuilder(a8142); // stick in stringbuilder - b8142.append(" SafeStuff"); // append some safe content - b8142.replace( - b8142.length() - "Chars".length(), - b8142.length(), - "Chars"); // replace some of the end content - java.util.HashMap map8142 = new java.util.HashMap(); - map8142.put("key8142", b8142.toString()); // put in a collection - String c8142 = (String) map8142.get("key8142"); // get it back out - String d8142 = c8142.substring(0, c8142.length() - 1); // extract most of it - String e8142 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d8142.getBytes()))); // B64 encode and decode it - String f8142 = e8142.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f8142); // reflection - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00120.java b/OWASP DATASET CLEANED/BenchmarkTest00120.java deleted file mode 100644 index 893bb42d2a5ee93364d44bacfc66d930d6457c7c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00120.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00120") -public class BenchmarkTest00120 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00120") != null) { - param = request.getHeader("BenchmarkTest00120"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz43804 = new StringBuilder(param); - bar = sbxyz43804.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00121.java b/OWASP DATASET CLEANED/BenchmarkTest00121.java deleted file mode 100644 index eeac03e8a92046642844eabe5ebc1461d09fd158..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00121.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00121") -public class BenchmarkTest00121 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00121") != null) { - param = request.getHeader("BenchmarkTest00121"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00122.java b/OWASP DATASET CLEANED/BenchmarkTest00122.java deleted file mode 100644 index 9dc618f3d6bf6050d9f2b91d0bf109a9adc0c8a3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00122.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00122") -public class BenchmarkTest00122 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00122") != null) { - param = request.getHeader("BenchmarkTest00122"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00123.java b/OWASP DATASET CLEANED/BenchmarkTest00123.java deleted file mode 100644 index 2869e95dd7c4f48807062794c3c30c61a2d0219e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00123.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00123") -public class BenchmarkTest00123 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00123") != null) { - param = request.getHeader("BenchmarkTest00123"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00124.java b/OWASP DATASET CLEANED/BenchmarkTest00124.java deleted file mode 100644 index d896eccdba374491e157a20b4b64baa625f2aa58..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00124.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00124") -public class BenchmarkTest00124 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00124") != null) { - param = request.getHeader("BenchmarkTest00124"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00125.java b/OWASP DATASET CLEANED/BenchmarkTest00125.java deleted file mode 100644 index f7e36690aeee8d18b41ae79a0daace5d0582f3c7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00125.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00125") -public class BenchmarkTest00125 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00125") != null) { - param = request.getHeader("BenchmarkTest00125"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00126.java b/OWASP DATASET CLEANED/BenchmarkTest00126.java deleted file mode 100644 index 90b106024c4aa30b70844c2039b0b3258d7d8dd6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00126.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00126") -public class BenchmarkTest00126 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00126") != null) { - param = request.getHeader("BenchmarkTest00126"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00127.java b/OWASP DATASET CLEANED/BenchmarkTest00127.java deleted file mode 100644 index 5192eaf3f00e463ad3ac7f1f8a463c3e0baca757..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00127.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00127") -public class BenchmarkTest00127 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00127") != null) { - param = request.getHeader("BenchmarkTest00127"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00128.java b/OWASP DATASET CLEANED/BenchmarkTest00128.java deleted file mode 100644 index 0a8d0a3a0cc58f23fc5f6fd9a24cacb6c72767b6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00128.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00128") -public class BenchmarkTest00128 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00128") != null) { - param = request.getHeader("BenchmarkTest00128"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00129.java b/OWASP DATASET CLEANED/BenchmarkTest00129.java deleted file mode 100644 index f3d4766958bdd757c8b1ad7d5c76d09bfc815244..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00129.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00129") -public class BenchmarkTest00129 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00129") != null) { - param = request.getHeader("BenchmarkTest00129"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00130.java b/OWASP DATASET CLEANED/BenchmarkTest00130.java deleted file mode 100644 index d9013fb9bd096933dc77807dab99f8fec4480fd8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00130.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00130") -public class BenchmarkTest00130 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00130") != null) { - param = request.getHeader("BenchmarkTest00130"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00131.java b/OWASP DATASET CLEANED/BenchmarkTest00131.java deleted file mode 100644 index 1ff9951b9dad1eb812472107985a5494770029bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00131.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00131") -public class BenchmarkTest00131 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00131") != null) { - param = request.getHeader("BenchmarkTest00131"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00132.java b/OWASP DATASET CLEANED/BenchmarkTest00132.java deleted file mode 100644 index 1137f02bcfede421f4ef02ef9acda277426674ed..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00132.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00132") -public class BenchmarkTest00132 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00132") != null) { - param = request.getHeader("BenchmarkTest00132"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00133.java b/OWASP DATASET CLEANED/BenchmarkTest00133.java deleted file mode 100644 index 4a280986b6cb384a1158c1ea83d8dffaf0f42aeb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00133.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00133") -public class BenchmarkTest00133 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00133") != null) { - param = request.getHeader("BenchmarkTest00133"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00134.java b/OWASP DATASET CLEANED/BenchmarkTest00134.java deleted file mode 100644 index f6ef36539ebb05fcaa0fa2ee39d32b2776322a1c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00134.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00134") -public class BenchmarkTest00134 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00134") != null) { - param = request.getHeader("BenchmarkTest00134"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00135.java b/OWASP DATASET CLEANED/BenchmarkTest00135.java deleted file mode 100644 index 706d601c62c39e9ba186eb603c3e42931f682d1d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00135.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00135") -public class BenchmarkTest00135 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00135") != null) { - param = request.getHeader("BenchmarkTest00135"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00136.java b/OWASP DATASET CLEANED/BenchmarkTest00136.java deleted file mode 100644 index 7c0dccfd42479b789a1d8292404479600fa389d6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00136.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00136") -public class BenchmarkTest00136 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00136") != null) { - param = request.getHeader("BenchmarkTest00136"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00137.java b/OWASP DATASET CLEANED/BenchmarkTest00137.java deleted file mode 100644 index b9e3febf72501d9a9af867b50c53673f0f843d17..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00137.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00137") -public class BenchmarkTest00137 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00137") != null) { - param = request.getHeader("BenchmarkTest00137"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map53289 = new java.util.HashMap(); - map53289.put("keyA-53289", "a_Value"); // put some stuff in the collection - map53289.put("keyB-53289", param); // put it in a collection - map53289.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map53289.get("keyB-53289"); // get it back out - bar = (String) map53289.get("keyA-53289"); // get safe value back out - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00138.java b/OWASP DATASET CLEANED/BenchmarkTest00138.java deleted file mode 100644 index 04d28e6ef7d11fc6f74f2bafe8c496f2fd15dee4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00138.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00138") -public class BenchmarkTest00138 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00138") != null) { - param = request.getHeader("BenchmarkTest00138"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00139.java b/OWASP DATASET CLEANED/BenchmarkTest00139.java deleted file mode 100644 index 06f78927f91122ad79b205bb68e55c54de7149ba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00139.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00139") -public class BenchmarkTest00139 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00139") != null) { - param = request.getHeader("BenchmarkTest00139"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a48394 = param; // assign - StringBuilder b48394 = new StringBuilder(a48394); // stick in stringbuilder - b48394.append(" SafeStuff"); // append some safe content - b48394.replace( - b48394.length() - "Chars".length(), - b48394.length(), - "Chars"); // replace some of the end content - java.util.HashMap map48394 = new java.util.HashMap(); - map48394.put("key48394", b48394.toString()); // put in a collection - String c48394 = (String) map48394.get("key48394"); // get it back out - String d48394 = c48394.substring(0, c48394.length() - 1); // extract most of it - String e48394 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d48394.getBytes()))); // B64 encode and decode it - String f48394 = e48394.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g48394 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g48394); // reflection - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00140.java b/OWASP DATASET CLEANED/BenchmarkTest00140.java deleted file mode 100644 index 31b9bdc4c7decdc8f2cc7ec27c74eac1ab7e7607..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00140.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00140") -public class BenchmarkTest00140 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00140") != null) { - param = request.getHeader("BenchmarkTest00140"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00141.java b/OWASP DATASET CLEANED/BenchmarkTest00141.java deleted file mode 100644 index b6bb3d4d83117561d86d9bbef1d9c78b4bc22b26..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00141.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00141") -public class BenchmarkTest00141 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00141") != null) { - param = request.getHeader("BenchmarkTest00141"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00142.java b/OWASP DATASET CLEANED/BenchmarkTest00142.java deleted file mode 100644 index 61e88c935dbcab096a5bc46ae25ac25207ec4e9c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00142.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00142") -public class BenchmarkTest00142 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00142") != null) { - param = request.getHeader("BenchmarkTest00142"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00143.java b/OWASP DATASET CLEANED/BenchmarkTest00143.java deleted file mode 100644 index d20c36d262e339729e8c59d0b9a056db0c230fee..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00143.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00143") -public class BenchmarkTest00143 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00143") != null) { - param = request.getHeader("BenchmarkTest00143"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00144.java b/OWASP DATASET CLEANED/BenchmarkTest00144.java deleted file mode 100644 index 4638da678c6203b6b86c39ce35a1e12c651fc4aa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00144.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00144") -public class BenchmarkTest00144 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00145.java b/OWASP DATASET CLEANED/BenchmarkTest00145.java deleted file mode 100644 index 15129f4b018a2dc6aa2fd61c18199d52d18a83f8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00145.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00145") -public class BenchmarkTest00145 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map17589 = new java.util.HashMap(); - map17589.put("keyA-17589", "a-Value"); // put some stuff in the collection - map17589.put("keyB-17589", param); // put it in a collection - map17589.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map17589.get("keyB-17589"); // get it back out - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00146.java b/OWASP DATASET CLEANED/BenchmarkTest00146.java deleted file mode 100644 index 30ccd6d74f0c76b679ae377db3dc48ad2992712e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00146.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00146") -public class BenchmarkTest00146 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz67327 = new StringBuilder(param); - bar = sbxyz67327.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00147.java b/OWASP DATASET CLEANED/BenchmarkTest00147.java deleted file mode 100644 index f714badb2c2fb86f93c7b36e7bc04d4c3c5d5893..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00147.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00147") -public class BenchmarkTest00147 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00148.java b/OWASP DATASET CLEANED/BenchmarkTest00148.java deleted file mode 100644 index 368d66c5c86dbf0e932e9f01aab072d7d28681ca..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00148.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00148") -public class BenchmarkTest00148 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00149.java b/OWASP DATASET CLEANED/BenchmarkTest00149.java deleted file mode 100644 index 329650dc1dfc45e2ee42739f7d43ddf3a5d79e4c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00149.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00149") -public class BenchmarkTest00149 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - StringBuilder sbxyz19132 = new StringBuilder(param); - String bar = sbxyz19132.append("_SafeStuff").toString(); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00150.java b/OWASP DATASET CLEANED/BenchmarkTest00150.java deleted file mode 100644 index 39baf141418fc51551b17a14bb08a8728edd53f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00150.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00150") -public class BenchmarkTest00150 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00151.java b/OWASP DATASET CLEANED/BenchmarkTest00151.java deleted file mode 100644 index e530e70eb59522d473953f23d4fe7b23ca2b7e6f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00151.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00151") -public class BenchmarkTest00151 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00152.java b/OWASP DATASET CLEANED/BenchmarkTest00152.java deleted file mode 100644 index 905919555a9312ea5a79fb25cf9b5fa2d3638a24..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00152.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00152") -public class BenchmarkTest00152 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00153.java b/OWASP DATASET CLEANED/BenchmarkTest00153.java deleted file mode 100644 index 84410887a0f7be1d463c8bb78c1cda7a3d6c2930..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00153.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00153") -public class BenchmarkTest00153 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map96050 = new java.util.HashMap(); - map96050.put("keyA-96050", "a-Value"); // put some stuff in the collection - map96050.put("keyB-96050", param); // put it in a collection - map96050.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map96050.get("keyB-96050"); // get it back out - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00154.java b/OWASP DATASET CLEANED/BenchmarkTest00154.java deleted file mode 100644 index 577a0f341e2c0aa88563191696a29f4d908e8f53..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00154.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00154") -public class BenchmarkTest00154 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00155.java b/OWASP DATASET CLEANED/BenchmarkTest00155.java deleted file mode 100644 index f709a012d57ec649370bf001e9ff8888c6488d60..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00155.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00155") -public class BenchmarkTest00155 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00156.java b/OWASP DATASET CLEANED/BenchmarkTest00156.java deleted file mode 100644 index d6b2b741fc1899cdef8912c3fc3d652326738b51..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00156.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00156") -public class BenchmarkTest00156 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00157.java b/OWASP DATASET CLEANED/BenchmarkTest00157.java deleted file mode 100644 index cb0f518c06a921df3460e27d0e61ef57ac3b7ec6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00157.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00157") -public class BenchmarkTest00157 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00158.java b/OWASP DATASET CLEANED/BenchmarkTest00158.java deleted file mode 100644 index bf3f04011f29f27cf058da76240a08861a508bcb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00158.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00158") -public class BenchmarkTest00158 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00158") != null) { - param = request.getHeader("BenchmarkTest00158"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00159.java b/OWASP DATASET CLEANED/BenchmarkTest00159.java deleted file mode 100644 index 03c1660b58c3f16a87ff54114498af76239e974e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00159.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00159") -public class BenchmarkTest00159 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00159") != null) { - param = request.getHeader("BenchmarkTest00159"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00160.java b/OWASP DATASET CLEANED/BenchmarkTest00160.java deleted file mode 100644 index 0d667252d6cf0234f0c520e4fb4b70a1c8f72dad..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00160.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00160") -public class BenchmarkTest00160 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00160") != null) { - param = request.getHeader("BenchmarkTest00160"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00161.java b/OWASP DATASET CLEANED/BenchmarkTest00161.java deleted file mode 100644 index eb6b25098cb4309a851114ff7d367b87f5600ba7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00161.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00161") -public class BenchmarkTest00161 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00161") != null) { - param = request.getHeader("BenchmarkTest00161"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map91760 = new java.util.HashMap(); - map91760.put("keyA-91760", "a_Value"); // put some stuff in the collection - map91760.put("keyB-91760", param); // put it in a collection - map91760.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map91760.get("keyB-91760"); // get it back out - bar = (String) map91760.get("keyA-91760"); // get safe value back out - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00162.java b/OWASP DATASET CLEANED/BenchmarkTest00162.java deleted file mode 100644 index 8ee8b4d1b528385067839447510b624d336f0c8b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00162.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00162") -public class BenchmarkTest00162 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00162") != null) { - param = request.getHeader("BenchmarkTest00162"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00163.java b/OWASP DATASET CLEANED/BenchmarkTest00163.java deleted file mode 100644 index 8df34551ec23cc864b45016ee89b1578ecfac5e3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00163.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00163") -public class BenchmarkTest00163 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00163") != null) { - param = request.getHeader("BenchmarkTest00163"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - StringBuilder sbxyz89305 = new StringBuilder(param); - String bar = sbxyz89305.append("_SafeStuff").toString(); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00164.java b/OWASP DATASET CLEANED/BenchmarkTest00164.java deleted file mode 100644 index 79ff234e0c7a94d08c1f604acf12181386d9d760..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00164.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00164") -public class BenchmarkTest00164 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00164") != null) { - param = request.getHeader("BenchmarkTest00164"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00165.java b/OWASP DATASET CLEANED/BenchmarkTest00165.java deleted file mode 100644 index 94a570566c4359b2af703ffad6930e8915557661..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00165.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00165") -public class BenchmarkTest00165 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00165") != null) { - param = request.getHeader("BenchmarkTest00165"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00166.java b/OWASP DATASET CLEANED/BenchmarkTest00166.java deleted file mode 100644 index 45bc5f4e384a7637cb229fb64128c24760735060..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00166.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00166") -public class BenchmarkTest00166 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00166") != null) { - param = request.getHeader("BenchmarkTest00166"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00167.java b/OWASP DATASET CLEANED/BenchmarkTest00167.java deleted file mode 100644 index a9428f90a3b3a35c277d51b17b7369da6f2d25e6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00167.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00167") -public class BenchmarkTest00167 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00167") != null) { - param = request.getHeader("BenchmarkTest00167"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00168.java b/OWASP DATASET CLEANED/BenchmarkTest00168.java deleted file mode 100644 index 82d00266d6a09f701799d5d6893b01a2addc6d7e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00168.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00168") -public class BenchmarkTest00168 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00168") != null) { - param = request.getHeader("BenchmarkTest00168"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00169.java b/OWASP DATASET CLEANED/BenchmarkTest00169.java deleted file mode 100644 index 4a05d35b12ba11572342b99b06fb84bd84ed524a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00169.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00169") -public class BenchmarkTest00169 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00169") != null) { - param = request.getHeader("BenchmarkTest00169"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00170.java b/OWASP DATASET CLEANED/BenchmarkTest00170.java deleted file mode 100644 index 6a6cc55b40db3c60030a22dab3e4a5b327afb393..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00170.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00170") -public class BenchmarkTest00170 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00170") != null) { - param = request.getHeader("BenchmarkTest00170"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a9823 = param; // assign - StringBuilder b9823 = new StringBuilder(a9823); // stick in stringbuilder - b9823.append(" SafeStuff"); // append some safe content - b9823.replace( - b9823.length() - "Chars".length(), - b9823.length(), - "Chars"); // replace some of the end content - java.util.HashMap map9823 = new java.util.HashMap(); - map9823.put("key9823", b9823.toString()); // put in a collection - String c9823 = (String) map9823.get("key9823"); // get it back out - String d9823 = c9823.substring(0, c9823.length() - 1); // extract most of it - String e9823 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d9823.getBytes()))); // B64 encode and decode it - String f9823 = e9823.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g9823 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g9823); // reflection - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00171.java b/OWASP DATASET CLEANED/BenchmarkTest00171.java deleted file mode 100644 index fe7d47dd20fe2c2c94b05c5ac47250b54c9f396c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00171.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00171") -public class BenchmarkTest00171 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00171") != null) { - param = request.getHeader("BenchmarkTest00171"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map40534 = new java.util.HashMap(); - map40534.put("keyA-40534", "a_Value"); // put some stuff in the collection - map40534.put("keyB-40534", param); // put it in a collection - map40534.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map40534.get("keyB-40534"); // get it back out - bar = (String) map40534.get("keyA-40534"); // get safe value back out - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00172.java b/OWASP DATASET CLEANED/BenchmarkTest00172.java deleted file mode 100644 index 847470f24adf582f5eba85a9a4c32d355711c6e1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00172.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00172") -public class BenchmarkTest00172 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00172") != null) { - param = request.getHeader("BenchmarkTest00172"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map59408 = new java.util.HashMap(); - map59408.put("keyA-59408", "a-Value"); // put some stuff in the collection - map59408.put("keyB-59408", param); // put it in a collection - map59408.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map59408.get("keyB-59408"); // get it back out - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00173.java b/OWASP DATASET CLEANED/BenchmarkTest00173.java deleted file mode 100644 index 4a195b927bac0c3cd9bb47f7ca8c85da2da1a7f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00173.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00173") -public class BenchmarkTest00173 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00173") != null) { - param = request.getHeader("BenchmarkTest00173"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map68097 = new java.util.HashMap(); - map68097.put("keyA-68097", "a-Value"); // put some stuff in the collection - map68097.put("keyB-68097", param); // put it in a collection - map68097.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map68097.get("keyB-68097"); // get it back out - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00174.java b/OWASP DATASET CLEANED/BenchmarkTest00174.java deleted file mode 100644 index f086b7cb574bc150e217dbf457926532af8a25a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00174.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00174") -public class BenchmarkTest00174 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00174") != null) { - param = request.getHeader("BenchmarkTest00174"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00175.java b/OWASP DATASET CLEANED/BenchmarkTest00175.java deleted file mode 100644 index 5bcda084605db96e0118e81e6144a6b55d85c43a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00175.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00175") -public class BenchmarkTest00175 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00175") != null) { - param = request.getHeader("BenchmarkTest00175"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map50591 = new java.util.HashMap(); - map50591.put("keyA-50591", "a_Value"); // put some stuff in the collection - map50591.put("keyB-50591", param); // put it in a collection - map50591.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map50591.get("keyB-50591"); // get it back out - bar = (String) map50591.get("keyA-50591"); // get safe value back out - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00176.java b/OWASP DATASET CLEANED/BenchmarkTest00176.java deleted file mode 100644 index 0a6916f3e6288e0c2c10fd7b49d6f9608f0dabb7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00176.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00176") -public class BenchmarkTest00176 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00176") != null) { - param = request.getHeader("BenchmarkTest00176"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00177.java b/OWASP DATASET CLEANED/BenchmarkTest00177.java deleted file mode 100644 index f5b663ce6faeeac8eed45895c0b572dbe60d3c19..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00177.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00177") -public class BenchmarkTest00177 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00177") != null) { - param = request.getHeader("BenchmarkTest00177"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00178.java b/OWASP DATASET CLEANED/BenchmarkTest00178.java deleted file mode 100644 index 1463e976c3abc89ff2e1b8b831a6aa2de79b5daa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00178.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00178") -public class BenchmarkTest00178 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00178") != null) { - param = request.getHeader("BenchmarkTest00178"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00179.java b/OWASP DATASET CLEANED/BenchmarkTest00179.java deleted file mode 100644 index 32bfc396d695f8fd12320e97d0d6da93012a3db5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00179.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00179") -public class BenchmarkTest00179 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00179") != null) { - param = request.getHeader("BenchmarkTest00179"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00180.java b/OWASP DATASET CLEANED/BenchmarkTest00180.java deleted file mode 100644 index 5766f679d1687b572a47cc2e5fd89433caab4091..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00180.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00180") -public class BenchmarkTest00180 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00180") != null) { - param = request.getHeader("BenchmarkTest00180"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00181.java b/OWASP DATASET CLEANED/BenchmarkTest00181.java deleted file mode 100644 index 1e8ab75c4bcc6067df5745ef658a86d741f6e1fe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00181.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00181") -public class BenchmarkTest00181 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00181") != null) { - param = request.getHeader("BenchmarkTest00181"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00182.java b/OWASP DATASET CLEANED/BenchmarkTest00182.java deleted file mode 100644 index 4106cc18b0d63f42c1ba30032630910c45ad83c7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00182.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00182") -public class BenchmarkTest00182 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00182") != null) { - param = request.getHeader("BenchmarkTest00182"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a48649 = param; // assign - StringBuilder b48649 = new StringBuilder(a48649); // stick in stringbuilder - b48649.append(" SafeStuff"); // append some safe content - b48649.replace( - b48649.length() - "Chars".length(), - b48649.length(), - "Chars"); // replace some of the end content - java.util.HashMap map48649 = new java.util.HashMap(); - map48649.put("key48649", b48649.toString()); // put in a collection - String c48649 = (String) map48649.get("key48649"); // get it back out - String d48649 = c48649.substring(0, c48649.length() - 1); // extract most of it - String e48649 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d48649.getBytes()))); // B64 encode and decode it - String f48649 = e48649.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g48649 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g48649); // reflection - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00183.java b/OWASP DATASET CLEANED/BenchmarkTest00183.java deleted file mode 100644 index 03ea2fa671240845982beeb2e80c5c166503a5ea..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00183.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00183") -public class BenchmarkTest00183 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00183") != null) { - param = request.getHeader("BenchmarkTest00183"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00184.java b/OWASP DATASET CLEANED/BenchmarkTest00184.java deleted file mode 100644 index b4a000b8c6a000d78cf2f936b9959266336a40b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00184.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00184") -public class BenchmarkTest00184 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00184") != null) { - param = request.getHeader("BenchmarkTest00184"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map46743 = new java.util.HashMap(); - map46743.put("keyA-46743", "a-Value"); // put some stuff in the collection - map46743.put("keyB-46743", param); // put it in a collection - map46743.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map46743.get("keyB-46743"); // get it back out - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00185.java b/OWASP DATASET CLEANED/BenchmarkTest00185.java deleted file mode 100644 index 5857f480c1f8d30bdf7dda6464f85a50576f645b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00185.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00185") -public class BenchmarkTest00185 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00185") != null) { - param = request.getHeader("BenchmarkTest00185"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map60659 = new java.util.HashMap(); - map60659.put("keyA-60659", "a_Value"); // put some stuff in the collection - map60659.put("keyB-60659", param); // put it in a collection - map60659.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map60659.get("keyB-60659"); // get it back out - bar = (String) map60659.get("keyA-60659"); // get safe value back out - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00186.java b/OWASP DATASET CLEANED/BenchmarkTest00186.java deleted file mode 100644 index fd833585dc0badf35070972a13f91a99e54232c4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00186.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00186") -public class BenchmarkTest00186 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00186") != null) { - param = request.getHeader("BenchmarkTest00186"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a18509 = param; // assign - StringBuilder b18509 = new StringBuilder(a18509); // stick in stringbuilder - b18509.append(" SafeStuff"); // append some safe content - b18509.replace( - b18509.length() - "Chars".length(), - b18509.length(), - "Chars"); // replace some of the end content - java.util.HashMap map18509 = new java.util.HashMap(); - map18509.put("key18509", b18509.toString()); // put in a collection - String c18509 = (String) map18509.get("key18509"); // get it back out - String d18509 = c18509.substring(0, c18509.length() - 1); // extract most of it - String e18509 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d18509.getBytes()))); // B64 encode and decode it - String f18509 = e18509.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g18509 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g18509); // reflection - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00187.java b/OWASP DATASET CLEANED/BenchmarkTest00187.java deleted file mode 100644 index 84603b9b741b37869b4b95ae0f4f727349fd69c7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00187.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00187") -public class BenchmarkTest00187 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00187") != null) { - param = request.getHeader("BenchmarkTest00187"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00188.java b/OWASP DATASET CLEANED/BenchmarkTest00188.java deleted file mode 100644 index 022c204b3441c02a128bc546decb84c358b2cb9e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00188.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00188") -public class BenchmarkTest00188 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00188") != null) { - param = request.getHeader("BenchmarkTest00188"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00189.java b/OWASP DATASET CLEANED/BenchmarkTest00189.java deleted file mode 100644 index 74f43ee145fa9da28cbfae5bcbdca102eb71b510..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00189.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00189") -public class BenchmarkTest00189 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00189") != null) { - param = request.getHeader("BenchmarkTest00189"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a14330 = param; // assign - StringBuilder b14330 = new StringBuilder(a14330); // stick in stringbuilder - b14330.append(" SafeStuff"); // append some safe content - b14330.replace( - b14330.length() - "Chars".length(), - b14330.length(), - "Chars"); // replace some of the end content - java.util.HashMap map14330 = new java.util.HashMap(); - map14330.put("key14330", b14330.toString()); // put in a collection - String c14330 = (String) map14330.get("key14330"); // get it back out - String d14330 = c14330.substring(0, c14330.length() - 1); // extract most of it - String e14330 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d14330.getBytes()))); // B64 encode and decode it - String f14330 = e14330.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g14330 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g14330); // reflection - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00190.java b/OWASP DATASET CLEANED/BenchmarkTest00190.java deleted file mode 100644 index a30e0c9b4adb5e5ae13b6bf8e86d86ecb9186657..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00190.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00190") -public class BenchmarkTest00190 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00190") != null) { - param = request.getHeader("BenchmarkTest00190"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00191.java b/OWASP DATASET CLEANED/BenchmarkTest00191.java deleted file mode 100644 index 9be0c09e500a5fd661329f9748dfa8514d4b0f10..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00191.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00191") -public class BenchmarkTest00191 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00191") != null) { - param = request.getHeader("BenchmarkTest00191"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00192.java b/OWASP DATASET CLEANED/BenchmarkTest00192.java deleted file mode 100644 index 605094f65b00d31a85e81e976c96648d7c7d62b0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00192.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00192") -public class BenchmarkTest00192 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00192") != null) { - param = request.getHeader("BenchmarkTest00192"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00193.java b/OWASP DATASET CLEANED/BenchmarkTest00193.java deleted file mode 100644 index f8930ef5168af19f0fc75b7fd6ae10e74f411f0c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00193.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00193") -public class BenchmarkTest00193 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00193") != null) { - param = request.getHeader("BenchmarkTest00193"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00194.java b/OWASP DATASET CLEANED/BenchmarkTest00194.java deleted file mode 100644 index a80f08636b7b5d5a9344bcfdb15c082b23f9503b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00194.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00194") -public class BenchmarkTest00194 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00194") != null) { - param = request.getHeader("BenchmarkTest00194"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00195.java b/OWASP DATASET CLEANED/BenchmarkTest00195.java deleted file mode 100644 index c986f56838d643050ff56df81e4e123673b314e4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00195.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00195") -public class BenchmarkTest00195 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00195") != null) { - param = request.getHeader("BenchmarkTest00195"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00196.java b/OWASP DATASET CLEANED/BenchmarkTest00196.java deleted file mode 100644 index 77a8276aedfb6624c4c2790bfe2816e7e058cff2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00196.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00196") -public class BenchmarkTest00196 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00196") != null) { - param = request.getHeader("BenchmarkTest00196"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00197.java b/OWASP DATASET CLEANED/BenchmarkTest00197.java deleted file mode 100644 index f4275e752a30f6bb9ac0902a9103cfc3651a9afb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00197.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00197") -public class BenchmarkTest00197 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00197") != null) { - param = request.getHeader("BenchmarkTest00197"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00198.java b/OWASP DATASET CLEANED/BenchmarkTest00198.java deleted file mode 100644 index 52d3c7cd3679ffbdc8d0bf623d09b688cbbe9d83..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00198.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00198") -public class BenchmarkTest00198 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00198") != null) { - param = request.getHeader("BenchmarkTest00198"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00199.java b/OWASP DATASET CLEANED/BenchmarkTest00199.java deleted file mode 100644 index b0239488b143dab0c883575cf35b19e0c4dd95fa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00199.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00199") -public class BenchmarkTest00199 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00199") != null) { - param = request.getHeader("BenchmarkTest00199"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00200.java b/OWASP DATASET CLEANED/BenchmarkTest00200.java deleted file mode 100644 index 168078f440b6b5b2fa281b5c3b9f61a2b8473c33..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00200.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00200") -public class BenchmarkTest00200 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00200") != null) { - param = request.getHeader("BenchmarkTest00200"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00201.java b/OWASP DATASET CLEANED/BenchmarkTest00201.java deleted file mode 100644 index b07ee826e9389db421c2b09583fd1f76cc663124..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00201.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00201") -public class BenchmarkTest00201 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00201") != null) { - param = request.getHeader("BenchmarkTest00201"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a60073 = param; // assign - StringBuilder b60073 = new StringBuilder(a60073); // stick in stringbuilder - b60073.append(" SafeStuff"); // append some safe content - b60073.replace( - b60073.length() - "Chars".length(), - b60073.length(), - "Chars"); // replace some of the end content - java.util.HashMap map60073 = new java.util.HashMap(); - map60073.put("key60073", b60073.toString()); // put in a collection - String c60073 = (String) map60073.get("key60073"); // get it back out - String d60073 = c60073.substring(0, c60073.length() - 1); // extract most of it - String e60073 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d60073.getBytes()))); // B64 encode and decode it - String f60073 = e60073.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g60073 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g60073); // reflection - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00202.java b/OWASP DATASET CLEANED/BenchmarkTest00202.java deleted file mode 100644 index c0f68de0fe14b64f78441afae676bef2d8698312..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00202.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00202") -public class BenchmarkTest00202 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00202") != null) { - param = request.getHeader("BenchmarkTest00202"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a15497 = param; // assign - StringBuilder b15497 = new StringBuilder(a15497); // stick in stringbuilder - b15497.append(" SafeStuff"); // append some safe content - b15497.replace( - b15497.length() - "Chars".length(), - b15497.length(), - "Chars"); // replace some of the end content - java.util.HashMap map15497 = new java.util.HashMap(); - map15497.put("key15497", b15497.toString()); // put in a collection - String c15497 = (String) map15497.get("key15497"); // get it back out - String d15497 = c15497.substring(0, c15497.length() - 1); // extract most of it - String e15497 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d15497.getBytes()))); // B64 encode and decode it - String f15497 = e15497.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g15497 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g15497); // reflection - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00203.java b/OWASP DATASET CLEANED/BenchmarkTest00203.java deleted file mode 100644 index 2af476ffab90893e0c4bb8937d72bd8fa9fe5344..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00203.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00203") -public class BenchmarkTest00203 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00203") != null) { - param = request.getHeader("BenchmarkTest00203"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00204.java b/OWASP DATASET CLEANED/BenchmarkTest00204.java deleted file mode 100644 index 0c57cef4ad0332b5c7e0a1c1510e4e73d6c1b237..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00204.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00204") -public class BenchmarkTest00204 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00204") != null) { - param = request.getHeader("BenchmarkTest00204"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00205.java b/OWASP DATASET CLEANED/BenchmarkTest00205.java deleted file mode 100644 index 354f00c30497b2b0df38fd8f7f016e072372e05d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00205.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00205") -public class BenchmarkTest00205 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00205") != null) { - param = request.getHeader("BenchmarkTest00205"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00206.java b/OWASP DATASET CLEANED/BenchmarkTest00206.java deleted file mode 100644 index 95014bc39fa4a6f86d77a216b42dfc85713d8a9c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00206.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00206") -public class BenchmarkTest00206 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00206") != null) { - param = request.getHeader("BenchmarkTest00206"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a13396 = param; // assign - StringBuilder b13396 = new StringBuilder(a13396); // stick in stringbuilder - b13396.append(" SafeStuff"); // append some safe content - b13396.replace( - b13396.length() - "Chars".length(), - b13396.length(), - "Chars"); // replace some of the end content - java.util.HashMap map13396 = new java.util.HashMap(); - map13396.put("key13396", b13396.toString()); // put in a collection - String c13396 = (String) map13396.get("key13396"); // get it back out - String d13396 = c13396.substring(0, c13396.length() - 1); // extract most of it - String e13396 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d13396.getBytes()))); // B64 encode and decode it - String f13396 = e13396.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g13396 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g13396); // reflection - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00207.java b/OWASP DATASET CLEANED/BenchmarkTest00207.java deleted file mode 100644 index 70ff7a52adfa2bc4bfebc9b4b503a0bcdf45ba14..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00207.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest00207") -public class BenchmarkTest00207 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest00207") != null) { - param = request.getHeader("BenchmarkTest00207"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00208.java b/OWASP DATASET CLEANED/BenchmarkTest00208.java deleted file mode 100644 index e2a7460927aabe0c3d01736777a74f0d0bce9f73..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00208.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00208") -public class BenchmarkTest00208 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00209.java b/OWASP DATASET CLEANED/BenchmarkTest00209.java deleted file mode 100644 index f0f5508c7f4a7fac99e8e2eb7dd94c31eab4cd91..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00209.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00209") -public class BenchmarkTest00209 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - StringBuilder sbxyz43235 = new StringBuilder(param); - String bar = sbxyz43235.append("_SafeStuff").toString(); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00210.java b/OWASP DATASET CLEANED/BenchmarkTest00210.java deleted file mode 100644 index 27939e7269f1683ee9e474802c426cea6a189234..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00210.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00210") -public class BenchmarkTest00210 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00211.java b/OWASP DATASET CLEANED/BenchmarkTest00211.java deleted file mode 100644 index 054a9c07ef26bdf23e51e528d09fbd2b2143738f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00211.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00211") -public class BenchmarkTest00211 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00212.java b/OWASP DATASET CLEANED/BenchmarkTest00212.java deleted file mode 100644 index 2a84fac295517f5e5e83f38b6e6c2fdb0a673523..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00212.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00212") -public class BenchmarkTest00212 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00213.java b/OWASP DATASET CLEANED/BenchmarkTest00213.java deleted file mode 100644 index ffe3c9f91cdb9a29b5aea1b92a2f5e8f25bf8dab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00213.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00213") -public class BenchmarkTest00213 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00214.java b/OWASP DATASET CLEANED/BenchmarkTest00214.java deleted file mode 100644 index 9cd8e1aeef25d6b9d3a55665f0f72fa4bc8c94b4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00214.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00214") -public class BenchmarkTest00214 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00215.java b/OWASP DATASET CLEANED/BenchmarkTest00215.java deleted file mode 100644 index 2acfcd4ddaa75f2b6b51714037821e95ad85b358..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00215.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00215") -public class BenchmarkTest00215 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = param; - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00216.java b/OWASP DATASET CLEANED/BenchmarkTest00216.java deleted file mode 100644 index a0376bad2dacbb0ff66f78593472f47941270a74..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00216.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00216") -public class BenchmarkTest00216 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00217.java b/OWASP DATASET CLEANED/BenchmarkTest00217.java deleted file mode 100644 index 0fff87e0ab90febe234a67e0ae09a064a44139be..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00217.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00217") -public class BenchmarkTest00217 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - // Chain a bunch of propagators in sequence - String a26348 = param; // assign - StringBuilder b26348 = new StringBuilder(a26348); // stick in stringbuilder - b26348.append(" SafeStuff"); // append some safe content - b26348.replace( - b26348.length() - "Chars".length(), - b26348.length(), - "Chars"); // replace some of the end content - java.util.HashMap map26348 = new java.util.HashMap(); - map26348.put("key26348", b26348.toString()); // put in a collection - String c26348 = (String) map26348.get("key26348"); // get it back out - String d26348 = c26348.substring(0, c26348.length() - 1); // extract most of it - String e26348 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d26348.getBytes()))); // B64 encode and decode it - String f26348 = e26348.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g26348 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g26348); // reflection - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00218.java b/OWASP DATASET CLEANED/BenchmarkTest00218.java deleted file mode 100644 index 690cb4259ecdc65e0ee8d28e5a139a515abfae2f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00218.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00218") -public class BenchmarkTest00218 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00219.java b/OWASP DATASET CLEANED/BenchmarkTest00219.java deleted file mode 100644 index 2500cdb960c9e058519442fefcbfbef2dff649e4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00219.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00219") -public class BenchmarkTest00219 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00220.java b/OWASP DATASET CLEANED/BenchmarkTest00220.java deleted file mode 100644 index b1911535a76f6a6d8bfdeff1a55148dab75de116..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00220.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00220") -public class BenchmarkTest00220 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - // Chain a bunch of propagators in sequence - String a25969 = param; // assign - StringBuilder b25969 = new StringBuilder(a25969); // stick in stringbuilder - b25969.append(" SafeStuff"); // append some safe content - b25969.replace( - b25969.length() - "Chars".length(), - b25969.length(), - "Chars"); // replace some of the end content - java.util.HashMap map25969 = new java.util.HashMap(); - map25969.put("key25969", b25969.toString()); // put in a collection - String c25969 = (String) map25969.get("key25969"); // get it back out - String d25969 = c25969.substring(0, c25969.length() - 1); // extract most of it - String e25969 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d25969.getBytes()))); // B64 encode and decode it - String f25969 = e25969.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g25969 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g25969); // reflection - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00221.java b/OWASP DATASET CLEANED/BenchmarkTest00221.java deleted file mode 100644 index 566323eec31f0f022039c9de4c41577ed9d2ef68..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00221.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00221") -public class BenchmarkTest00221 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00222.java b/OWASP DATASET CLEANED/BenchmarkTest00222.java deleted file mode 100644 index 2347f3c1b982f63afa4745f55fa765e1fc8d91db..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00222.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00222") -public class BenchmarkTest00222 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00223.java b/OWASP DATASET CLEANED/BenchmarkTest00223.java deleted file mode 100644 index 199272a2b3cbc46dccc85a8f6f7715c4ef770e73..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00223.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00223") -public class BenchmarkTest00223 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = "safe!"; - java.util.HashMap map13848 = new java.util.HashMap(); - map13848.put("keyA-13848", "a-Value"); // put some stuff in the collection - map13848.put("keyB-13848", param); // put it in a collection - map13848.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map13848.get("keyB-13848"); // get it back out - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00224.java b/OWASP DATASET CLEANED/BenchmarkTest00224.java deleted file mode 100644 index aeccf9d685e34136c90d96d3803c23f77a3d0da3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00224.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00224") -public class BenchmarkTest00224 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = param; - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00225.java b/OWASP DATASET CLEANED/BenchmarkTest00225.java deleted file mode 100644 index 4eed2bdab279d1bc322329b8af791eff128c9300..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00225.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00225") -public class BenchmarkTest00225 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00226.java b/OWASP DATASET CLEANED/BenchmarkTest00226.java deleted file mode 100644 index ba20ee9375bca9accdcff18d47ce0a424606146b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00226.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00226") -public class BenchmarkTest00226 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = "safe!"; - java.util.HashMap map56895 = new java.util.HashMap(); - map56895.put("keyA-56895", "a_Value"); // put some stuff in the collection - map56895.put("keyB-56895", param); // put it in a collection - map56895.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map56895.get("keyB-56895"); // get it back out - bar = (String) map56895.get("keyA-56895"); // get safe value back out - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00227.java b/OWASP DATASET CLEANED/BenchmarkTest00227.java deleted file mode 100644 index 97c1e4bab59c81862e261f5f81f1c5d0293cf8e9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00227.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00227") -public class BenchmarkTest00227 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - // Chain a bunch of propagators in sequence - String a15913 = param; // assign - StringBuilder b15913 = new StringBuilder(a15913); // stick in stringbuilder - b15913.append(" SafeStuff"); // append some safe content - b15913.replace( - b15913.length() - "Chars".length(), - b15913.length(), - "Chars"); // replace some of the end content - java.util.HashMap map15913 = new java.util.HashMap(); - map15913.put("key15913", b15913.toString()); // put in a collection - String c15913 = (String) map15913.get("key15913"); // get it back out - String d15913 = c15913.substring(0, c15913.length() - 1); // extract most of it - String e15913 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d15913.getBytes()))); // B64 encode and decode it - String f15913 = e15913.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g15913 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g15913); // reflection - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00228.java b/OWASP DATASET CLEANED/BenchmarkTest00228.java deleted file mode 100644 index 17dfc2b658d26a6c9d85d4fdb664c79d24e2aa73..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00228.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00228") -public class BenchmarkTest00228 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00229.java b/OWASP DATASET CLEANED/BenchmarkTest00229.java deleted file mode 100644 index 0912a4a94f846d5e191ce5b18fb80e599bbbbe74..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00229.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00229") -public class BenchmarkTest00229 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00230.java b/OWASP DATASET CLEANED/BenchmarkTest00230.java deleted file mode 100644 index 9d1358ff4851e6ad0b4fe54b16b4f09efbeb52af..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00230.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00230") -public class BenchmarkTest00230 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00231.java b/OWASP DATASET CLEANED/BenchmarkTest00231.java deleted file mode 100644 index 28fdfa5db7b42a4943de7245c9710c3f87120c40..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00231.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00231") -public class BenchmarkTest00231 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = "safe!"; - java.util.HashMap map59585 = new java.util.HashMap(); - map59585.put("keyA-59585", "a-Value"); // put some stuff in the collection - map59585.put("keyB-59585", param); // put it in a collection - map59585.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map59585.get("keyB-59585"); // get it back out - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00232.java b/OWASP DATASET CLEANED/BenchmarkTest00232.java deleted file mode 100644 index 440a79529ffccf9d9ada0a0f36a2cae9ea9e2ff0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00232.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00232") -public class BenchmarkTest00232 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = "safe!"; - java.util.HashMap map84140 = new java.util.HashMap(); - map84140.put("keyA-84140", "a_Value"); // put some stuff in the collection - map84140.put("keyB-84140", param); // put it in a collection - map84140.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map84140.get("keyB-84140"); // get it back out - bar = (String) map84140.get("keyA-84140"); // get safe value back out - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00233.java b/OWASP DATASET CLEANED/BenchmarkTest00233.java deleted file mode 100644 index 503504217503dc9e72bdf5b2ff24034b48ce49ae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00233.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00233") -public class BenchmarkTest00233 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00234.java b/OWASP DATASET CLEANED/BenchmarkTest00234.java deleted file mode 100644 index 95adcf40d9cbd306d71838cf8d118e20a956e595..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00234.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00234") -public class BenchmarkTest00234 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = "safe!"; - java.util.HashMap map35995 = new java.util.HashMap(); - map35995.put("keyA-35995", "a_Value"); // put some stuff in the collection - map35995.put("keyB-35995", param); // put it in a collection - map35995.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map35995.get("keyB-35995"); // get it back out - bar = (String) map35995.get("keyA-35995"); // get safe value back out - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00235.java b/OWASP DATASET CLEANED/BenchmarkTest00235.java deleted file mode 100644 index d5783a7b4ab1a79fb9a7c5faa368db4c8b02362a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00235.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00235") -public class BenchmarkTest00235 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00236.java b/OWASP DATASET CLEANED/BenchmarkTest00236.java deleted file mode 100644 index fe9c20ea47b1fe307287fb25f02d40135b631d2f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00236.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00236") -public class BenchmarkTest00236 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00237.java b/OWASP DATASET CLEANED/BenchmarkTest00237.java deleted file mode 100644 index 82a63a50a7caf3657356d1bbafcde9b3ca1d168c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00237.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00237") -public class BenchmarkTest00237 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00238.java b/OWASP DATASET CLEANED/BenchmarkTest00238.java deleted file mode 100644 index f37c526e4046d02b3e8947131aef775156a2c9ce..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00238.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00238") -public class BenchmarkTest00238 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00239.java b/OWASP DATASET CLEANED/BenchmarkTest00239.java deleted file mode 100644 index 6be15dd7243b27cd8912abaa82b9d101dfa8d615..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00239.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00239") -public class BenchmarkTest00239 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - // Chain a bunch of propagators in sequence - String a22450 = param; // assign - StringBuilder b22450 = new StringBuilder(a22450); // stick in stringbuilder - b22450.append(" SafeStuff"); // append some safe content - b22450.replace( - b22450.length() - "Chars".length(), - b22450.length(), - "Chars"); // replace some of the end content - java.util.HashMap map22450 = new java.util.HashMap(); - map22450.put("key22450", b22450.toString()); // put in a collection - String c22450 = (String) map22450.get("key22450"); // get it back out - String d22450 = c22450.substring(0, c22450.length() - 1); // extract most of it - String e22450 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d22450.getBytes()))); // B64 encode and decode it - String f22450 = e22450.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f22450); // reflection - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00240.java b/OWASP DATASET CLEANED/BenchmarkTest00240.java deleted file mode 100644 index 9ab4de1531260b8eee8914ea5ca92a4b67d088fa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00240.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00240") -public class BenchmarkTest00240 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00241.java b/OWASP DATASET CLEANED/BenchmarkTest00241.java deleted file mode 100644 index 65620d4ce1a09b01e151f4517d61d0a0bf23afab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00241.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00241") -public class BenchmarkTest00241 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00242.java b/OWASP DATASET CLEANED/BenchmarkTest00242.java deleted file mode 100644 index 83729931e47d4f488eb6f5c2ecbfd80452214c90..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00242.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00242") -public class BenchmarkTest00242 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00243.java b/OWASP DATASET CLEANED/BenchmarkTest00243.java deleted file mode 100644 index 4f7c79e357edef2c38e3389c216d612c72a81e6a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00243.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00243") -public class BenchmarkTest00243 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = "safe!"; - java.util.HashMap map86025 = new java.util.HashMap(); - map86025.put("keyA-86025", "a-Value"); // put some stuff in the collection - map86025.put("keyB-86025", param); // put it in a collection - map86025.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map86025.get("keyB-86025"); // get it back out - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00244.java b/OWASP DATASET CLEANED/BenchmarkTest00244.java deleted file mode 100644 index f758f33b90033e0ba707f0bd56d6094a1005100f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00244.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00244") -public class BenchmarkTest00244 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00245.java b/OWASP DATASET CLEANED/BenchmarkTest00245.java deleted file mode 100644 index 42f7494f13be08e8436d81a855126785a8edb637..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00245.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00245") -public class BenchmarkTest00245 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - // Chain a bunch of propagators in sequence - String a73565 = param; // assign - StringBuilder b73565 = new StringBuilder(a73565); // stick in stringbuilder - b73565.append(" SafeStuff"); // append some safe content - b73565.replace( - b73565.length() - "Chars".length(), - b73565.length(), - "Chars"); // replace some of the end content - java.util.HashMap map73565 = new java.util.HashMap(); - map73565.put("key73565", b73565.toString()); // put in a collection - String c73565 = (String) map73565.get("key73565"); // get it back out - String d73565 = c73565.substring(0, c73565.length() - 1); // extract most of it - String e73565 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d73565.getBytes()))); // B64 encode and decode it - String f73565 = e73565.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g73565 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g73565); // reflection - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00246.java b/OWASP DATASET CLEANED/BenchmarkTest00246.java deleted file mode 100644 index ddc6c3623aad70b65dc42b033d45833f3f85e3fc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00246.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00246") -public class BenchmarkTest00246 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00247.java b/OWASP DATASET CLEANED/BenchmarkTest00247.java deleted file mode 100644 index bc51413c36f070a0eb91b20b58bbac4271940d54..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00247.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00247") -public class BenchmarkTest00247 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz47256 = new StringBuilder(param); - bar = sbxyz47256.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00248.java b/OWASP DATASET CLEANED/BenchmarkTest00248.java deleted file mode 100644 index 17091c128b3c9ed335010fd4c90a857828535697..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00248.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00248") -public class BenchmarkTest00248 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00249.java b/OWASP DATASET CLEANED/BenchmarkTest00249.java deleted file mode 100644 index 86b2eb81a87f73ca5e8d8561f81aa0c8694b718a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00249.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00249") -public class BenchmarkTest00249 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00250.java b/OWASP DATASET CLEANED/BenchmarkTest00250.java deleted file mode 100644 index e31aba4449ca8265e5fbd799902df72abef23ee2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00250.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00250") -public class BenchmarkTest00250 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00251.java b/OWASP DATASET CLEANED/BenchmarkTest00251.java deleted file mode 100644 index d5146ddbf6626a6e97e323e08e2d2ac6595684ac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00251.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00251") -public class BenchmarkTest00251 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00252.java b/OWASP DATASET CLEANED/BenchmarkTest00252.java deleted file mode 100644 index 5ba961de52322466df5fed86b7d7dabbb4ce3f1d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00252.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00252") -public class BenchmarkTest00252 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00253.java b/OWASP DATASET CLEANED/BenchmarkTest00253.java deleted file mode 100644 index 216239210cc68f245a77850a205ec9dfc27bbb4c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00253.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00253") -public class BenchmarkTest00253 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00254.java b/OWASP DATASET CLEANED/BenchmarkTest00254.java deleted file mode 100644 index 21bcd5b09895b8b2baff62484ca2b49185627e10..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00254.java +++ /dev/null @@ -1,162 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00254") -public class BenchmarkTest00254 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00254"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00255.java b/OWASP DATASET CLEANED/BenchmarkTest00255.java deleted file mode 100644 index bb81e8379357428d3feae529b99a3eaf30d668c0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00255.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00255") -public class BenchmarkTest00255 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00255"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00256.java b/OWASP DATASET CLEANED/BenchmarkTest00256.java deleted file mode 100644 index 7a52b921b1a7cec7f027d40839bd81811823a053..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00256.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00256") -public class BenchmarkTest00256 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00256"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00257.java b/OWASP DATASET CLEANED/BenchmarkTest00257.java deleted file mode 100644 index c4969bb69ef490d99020fa65c772ff439d9743cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00257.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00257") -public class BenchmarkTest00257 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00257"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - StringBuilder sbxyz60568 = new StringBuilder(param); - String bar = sbxyz60568.append("_SafeStuff").toString(); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00258.java b/OWASP DATASET CLEANED/BenchmarkTest00258.java deleted file mode 100644 index 916d4c76c73db9fe7bc9ab9736596d2e81734e1a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00258.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00258") -public class BenchmarkTest00258 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00258"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00259.java b/OWASP DATASET CLEANED/BenchmarkTest00259.java deleted file mode 100644 index 3ca458a19a8eb2a99090918dcf34f9d393e12556..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00259.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00259") -public class BenchmarkTest00259 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00259"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00260.java b/OWASP DATASET CLEANED/BenchmarkTest00260.java deleted file mode 100644 index 35b23c55b25cd4f5e608326a3455f26f94f9c808..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00260.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00260") -public class BenchmarkTest00260 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00260"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00261.java b/OWASP DATASET CLEANED/BenchmarkTest00261.java deleted file mode 100644 index f9da71b74d5bec7e4b371fa245038880757a3cbd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00261.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00261") -public class BenchmarkTest00261 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00261"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a3000 = param; // assign - StringBuilder b3000 = new StringBuilder(a3000); // stick in stringbuilder - b3000.append(" SafeStuff"); // append some safe content - b3000.replace( - b3000.length() - "Chars".length(), - b3000.length(), - "Chars"); // replace some of the end content - java.util.HashMap map3000 = new java.util.HashMap(); - map3000.put("key3000", b3000.toString()); // put in a collection - String c3000 = (String) map3000.get("key3000"); // get it back out - String d3000 = c3000.substring(0, c3000.length() - 1); // extract most of it - String e3000 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d3000.getBytes()))); // B64 encode and decode it - String f3000 = e3000.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g3000 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g3000); // reflection - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00262.java b/OWASP DATASET CLEANED/BenchmarkTest00262.java deleted file mode 100644 index d896ae41f2fa87d79b63f9e47d37ad72ab4a519d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00262.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00262") -public class BenchmarkTest00262 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00262"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00263.java b/OWASP DATASET CLEANED/BenchmarkTest00263.java deleted file mode 100644 index 373607bd328ccf9c7febf542bb7ad4f6a6c07492..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00263.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00263") -public class BenchmarkTest00263 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00263"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00264.java b/OWASP DATASET CLEANED/BenchmarkTest00264.java deleted file mode 100644 index bd031aeaaa579654a4c1c1f94f3e3823531ac3b3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00264.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00264") -public class BenchmarkTest00264 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00264"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00265.java b/OWASP DATASET CLEANED/BenchmarkTest00265.java deleted file mode 100644 index 7ed741bc2797825ea3ec33b8239e8502907b1923..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00265.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00265") -public class BenchmarkTest00265 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00265"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00266.java b/OWASP DATASET CLEANED/BenchmarkTest00266.java deleted file mode 100644 index 4adee10a2e7e9d61d31db2c004a713607e6d130b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00266.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00266") -public class BenchmarkTest00266 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00266"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map42712 = new java.util.HashMap(); - map42712.put("keyA-42712", "a-Value"); // put some stuff in the collection - map42712.put("keyB-42712", param); // put it in a collection - map42712.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map42712.get("keyB-42712"); // get it back out - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00267.java b/OWASP DATASET CLEANED/BenchmarkTest00267.java deleted file mode 100644 index 3f714658f98cf4e39045b5a540b4babedc750f76..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00267.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00267") -public class BenchmarkTest00267 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00267"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - StringBuilder sbxyz11795 = new StringBuilder(param); - String bar = sbxyz11795.append("_SafeStuff").toString(); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00268.java b/OWASP DATASET CLEANED/BenchmarkTest00268.java deleted file mode 100644 index 30df332c720a4667932e6afdbc6a00e3f7d987dd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00268.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00268") -public class BenchmarkTest00268 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00268"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00269.java b/OWASP DATASET CLEANED/BenchmarkTest00269.java deleted file mode 100644 index 1021456d949a5155ed6432136a10711a79eef604..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00269.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00269") -public class BenchmarkTest00269 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00269"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00270.java b/OWASP DATASET CLEANED/BenchmarkTest00270.java deleted file mode 100644 index d9126b889d442510b37075e97680332a67fd99c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00270.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00270") -public class BenchmarkTest00270 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00270"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00271.java b/OWASP DATASET CLEANED/BenchmarkTest00271.java deleted file mode 100644 index e73ba4512cbe86868a4b8259329a0fa28c5c3704..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00271.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00271") -public class BenchmarkTest00271 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00271"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a75009 = param; // assign - StringBuilder b75009 = new StringBuilder(a75009); // stick in stringbuilder - b75009.append(" SafeStuff"); // append some safe content - b75009.replace( - b75009.length() - "Chars".length(), - b75009.length(), - "Chars"); // replace some of the end content - java.util.HashMap map75009 = new java.util.HashMap(); - map75009.put("key75009", b75009.toString()); // put in a collection - String c75009 = (String) map75009.get("key75009"); // get it back out - String d75009 = c75009.substring(0, c75009.length() - 1); // extract most of it - String e75009 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d75009.getBytes()))); // B64 encode and decode it - String f75009 = e75009.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f75009); // reflection - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00272.java b/OWASP DATASET CLEANED/BenchmarkTest00272.java deleted file mode 100644 index cb8b9edae2321e183e04b7a230853570b6c5b2a6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00272.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00272") -public class BenchmarkTest00272 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00272"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00273.java b/OWASP DATASET CLEANED/BenchmarkTest00273.java deleted file mode 100644 index 4af7de2fa62325285a6fe02aa1fc512c0145b19c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00273.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00273") -public class BenchmarkTest00273 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00273"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00274.java b/OWASP DATASET CLEANED/BenchmarkTest00274.java deleted file mode 100644 index f7a89044371a7bef6403d462243820af5209db6c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00274.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00274") -public class BenchmarkTest00274 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00274"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00275.java b/OWASP DATASET CLEANED/BenchmarkTest00275.java deleted file mode 100644 index a97e29fc74166329b1c394ccbef15a10886be38e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00275.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00275") -public class BenchmarkTest00275 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a28150 = param; // assign - StringBuilder b28150 = new StringBuilder(a28150); // stick in stringbuilder - b28150.append(" SafeStuff"); // append some safe content - b28150.replace( - b28150.length() - "Chars".length(), - b28150.length(), - "Chars"); // replace some of the end content - java.util.HashMap map28150 = new java.util.HashMap(); - map28150.put("key28150", b28150.toString()); // put in a collection - String c28150 = (String) map28150.get("key28150"); // get it back out - String d28150 = c28150.substring(0, c28150.length() - 1); // extract most of it - String e28150 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d28150.getBytes()))); // B64 encode and decode it - String f28150 = e28150.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g28150 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g28150); // reflection - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00276.java b/OWASP DATASET CLEANED/BenchmarkTest00276.java deleted file mode 100644 index b889dc4ecb2bb324048dfb9f69c9d5f252033c6e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00276.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00276") -public class BenchmarkTest00276 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00277.java b/OWASP DATASET CLEANED/BenchmarkTest00277.java deleted file mode 100644 index 78130e9157055604e953628d05c007f7d5073d12..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00277.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00277") -public class BenchmarkTest00277 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a54571 = param; // assign - StringBuilder b54571 = new StringBuilder(a54571); // stick in stringbuilder - b54571.append(" SafeStuff"); // append some safe content - b54571.replace( - b54571.length() - "Chars".length(), - b54571.length(), - "Chars"); // replace some of the end content - java.util.HashMap map54571 = new java.util.HashMap(); - map54571.put("key54571", b54571.toString()); // put in a collection - String c54571 = (String) map54571.get("key54571"); // get it back out - String d54571 = c54571.substring(0, c54571.length() - 1); // extract most of it - String e54571 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d54571.getBytes()))); // B64 encode and decode it - String f54571 = e54571.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g54571 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g54571); // reflection - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00278.java b/OWASP DATASET CLEANED/BenchmarkTest00278.java deleted file mode 100644 index 1322fb1be8ac262904d849d16fd240f1d556ab76..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00278.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00278") -public class BenchmarkTest00278 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00279.java b/OWASP DATASET CLEANED/BenchmarkTest00279.java deleted file mode 100644 index 4ebe2d25b974a2f88bd99c713e2c2eefea7ae3ec..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00279.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00279") -public class BenchmarkTest00279 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00280.java b/OWASP DATASET CLEANED/BenchmarkTest00280.java deleted file mode 100644 index b8d9cc3ec646dfbf8843079794f02edc68b54620..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00280.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00280") -public class BenchmarkTest00280 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00281.java b/OWASP DATASET CLEANED/BenchmarkTest00281.java deleted file mode 100644 index 8e76827cb633b7676f2d86563225cc9c1c22dc54..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00281.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00281") -public class BenchmarkTest00281 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00282.java b/OWASP DATASET CLEANED/BenchmarkTest00282.java deleted file mode 100644 index f2eb0a6410f6370d0e15250ebce547dfb715a806..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00282.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00282") -public class BenchmarkTest00282 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00283.java b/OWASP DATASET CLEANED/BenchmarkTest00283.java deleted file mode 100644 index 4dc280288f3c28117ad80dd193523e013f0b71a9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00283.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00283") -public class BenchmarkTest00283 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00284.java b/OWASP DATASET CLEANED/BenchmarkTest00284.java deleted file mode 100644 index e747254ae9bb171bab59cd81d0774598e8f02c4d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00284.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00284") -public class BenchmarkTest00284 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00285.java b/OWASP DATASET CLEANED/BenchmarkTest00285.java deleted file mode 100644 index cf1b75cd4fa9ff56961a7ce0c541c74c1316adc2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00285.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00285") -public class BenchmarkTest00285 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00286.java b/OWASP DATASET CLEANED/BenchmarkTest00286.java deleted file mode 100644 index 5931242784e2a788c5d999b59b30ef1b78e6edc9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00286.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00286") -public class BenchmarkTest00286 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00287.java b/OWASP DATASET CLEANED/BenchmarkTest00287.java deleted file mode 100644 index 75efb8da52f87af06324e80301b14f2d6ec6dc3b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00287.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00287") -public class BenchmarkTest00287 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00288.java b/OWASP DATASET CLEANED/BenchmarkTest00288.java deleted file mode 100644 index 25d314d1628601c29b1ed3eecc2ef9426742ff77..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00288.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00288") -public class BenchmarkTest00288 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map34285 = new java.util.HashMap(); - map34285.put("keyA-34285", "a_Value"); // put some stuff in the collection - map34285.put("keyB-34285", param); // put it in a collection - map34285.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map34285.get("keyB-34285"); // get it back out - bar = (String) map34285.get("keyA-34285"); // get safe value back out - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00289.java b/OWASP DATASET CLEANED/BenchmarkTest00289.java deleted file mode 100644 index 01ca02d0f87238add08980f410a880f56a08f7f2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00289.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00289") -public class BenchmarkTest00289 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00290.java b/OWASP DATASET CLEANED/BenchmarkTest00290.java deleted file mode 100644 index be683649787807d6f8bde7f3bbaa4f52b83c2e63..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00290.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00290") -public class BenchmarkTest00290 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - StringBuilder sbxyz73567 = new StringBuilder(param); - String bar = sbxyz73567.append("_SafeStuff").toString(); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00291.java b/OWASP DATASET CLEANED/BenchmarkTest00291.java deleted file mode 100644 index 8ed353c07a9f7ad96bfd433f36dbb01024111aad..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00291.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00291") -public class BenchmarkTest00291 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00292.java b/OWASP DATASET CLEANED/BenchmarkTest00292.java deleted file mode 100644 index cb23fe762a1894af0732af3eba880adf96902fe5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00292.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00292") -public class BenchmarkTest00292 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00293.java b/OWASP DATASET CLEANED/BenchmarkTest00293.java deleted file mode 100644 index 73a616ec51053ab643b08c19c42b644daeaaf6c9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00293.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00293") -public class BenchmarkTest00293 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00293"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00294.java b/OWASP DATASET CLEANED/BenchmarkTest00294.java deleted file mode 100644 index 6326a6e9afe3b075e634593926b1be849292ab5e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00294.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00294") -public class BenchmarkTest00294 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00294"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00295.java b/OWASP DATASET CLEANED/BenchmarkTest00295.java deleted file mode 100644 index 61b5910b1f688b0d3f59047bfcf11400169fcfd4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00295.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00295") -public class BenchmarkTest00295 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00295"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00296.java b/OWASP DATASET CLEANED/BenchmarkTest00296.java deleted file mode 100644 index 4f06b21867447023d428462ccc8f984497992fe6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00296.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00296") -public class BenchmarkTest00296 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00296"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00297.java b/OWASP DATASET CLEANED/BenchmarkTest00297.java deleted file mode 100644 index 3c9f399964a90f66a21e189e12925244416715e1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00297.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00297") -public class BenchmarkTest00297 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00297"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00298.java b/OWASP DATASET CLEANED/BenchmarkTest00298.java deleted file mode 100644 index c5e33ea76609ebcb1a807ebcb0ccd8fd4e77330a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00298.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00298") -public class BenchmarkTest00298 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00298"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00299.java b/OWASP DATASET CLEANED/BenchmarkTest00299.java deleted file mode 100644 index 03d90e0553a113e572b67f008c2a037993ea5267..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00299.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00299") -public class BenchmarkTest00299 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00299"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00300.java b/OWASP DATASET CLEANED/BenchmarkTest00300.java deleted file mode 100644 index 84fa5d0acf2a07b6f97464cfe1e6f8775823bce8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00300.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00300") -public class BenchmarkTest00300 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00300"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00301.java b/OWASP DATASET CLEANED/BenchmarkTest00301.java deleted file mode 100644 index 494c089219e4d34bdca35439299246336f5431f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00301.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00301") -public class BenchmarkTest00301 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map16074 = new java.util.HashMap(); - map16074.put("keyA-16074", "a-Value"); // put some stuff in the collection - map16074.put("keyB-16074", param); // put it in a collection - map16074.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map16074.get("keyB-16074"); // get it back out - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00302.java b/OWASP DATASET CLEANED/BenchmarkTest00302.java deleted file mode 100644 index 2207e9c023416e57a4d4560c4a980c68ae04071b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00302.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00302") -public class BenchmarkTest00302 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00302"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00303.java b/OWASP DATASET CLEANED/BenchmarkTest00303.java deleted file mode 100644 index 48733d9963ee98b558a731dfe2f02c2b1a89022a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00303.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00303") -public class BenchmarkTest00303 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00303"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00304.java b/OWASP DATASET CLEANED/BenchmarkTest00304.java deleted file mode 100644 index 93d96d0ff446f9af257bcc1b70f58e53f6cf6838..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00304.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00304") -public class BenchmarkTest00304 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00304"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00305.java b/OWASP DATASET CLEANED/BenchmarkTest00305.java deleted file mode 100644 index a73f460a61702b0f514f521d443b7c79e980f85a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00305.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00305") -public class BenchmarkTest00305 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00305"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a99928 = param; // assign - StringBuilder b99928 = new StringBuilder(a99928); // stick in stringbuilder - b99928.append(" SafeStuff"); // append some safe content - b99928.replace( - b99928.length() - "Chars".length(), - b99928.length(), - "Chars"); // replace some of the end content - java.util.HashMap map99928 = new java.util.HashMap(); - map99928.put("key99928", b99928.toString()); // put in a collection - String c99928 = (String) map99928.get("key99928"); // get it back out - String d99928 = c99928.substring(0, c99928.length() - 1); // extract most of it - String e99928 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d99928.getBytes()))); // B64 encode and decode it - String f99928 = e99928.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g99928 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g99928); // reflection - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00306.java b/OWASP DATASET CLEANED/BenchmarkTest00306.java deleted file mode 100644 index fd144cb66a4b4ed3bfdf4357e27150a2686e213f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00306.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00306") -public class BenchmarkTest00306 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00306"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00307.java b/OWASP DATASET CLEANED/BenchmarkTest00307.java deleted file mode 100644 index ac83e7438b8234310e66fa02ce9b38f637177047..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00307.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00307") -public class BenchmarkTest00307 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00307"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00308.java b/OWASP DATASET CLEANED/BenchmarkTest00308.java deleted file mode 100644 index d853f94f5236547b19172cd667874aa5aafcdd17..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00308.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00308") -public class BenchmarkTest00308 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00308"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00309.java b/OWASP DATASET CLEANED/BenchmarkTest00309.java deleted file mode 100644 index 59e5c1daa68e2c21957e8528b2700bbd18eb667d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00309.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00309") -public class BenchmarkTest00309 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00309"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map92785 = new java.util.HashMap(); - map92785.put("keyA-92785", "a_Value"); // put some stuff in the collection - map92785.put("keyB-92785", param); // put it in a collection - map92785.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map92785.get("keyB-92785"); // get it back out - bar = (String) map92785.get("keyA-92785"); // get safe value back out - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00310.java b/OWASP DATASET CLEANED/BenchmarkTest00310.java deleted file mode 100644 index 772d6b1fbb4589056b4539dd8e43dfce5d801413..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00310.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00310") -public class BenchmarkTest00310 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00310"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00311.java b/OWASP DATASET CLEANED/BenchmarkTest00311.java deleted file mode 100644 index ecc05a1f2aab3380437167271ad4e3d0c94525f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00311.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00311") -public class BenchmarkTest00311 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00311"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00312.java b/OWASP DATASET CLEANED/BenchmarkTest00312.java deleted file mode 100644 index f7f54cf69643d91192c39db09de4a1803a35d7ea..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00312.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00312") -public class BenchmarkTest00312 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00312"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00313.java b/OWASP DATASET CLEANED/BenchmarkTest00313.java deleted file mode 100644 index 3e9bb13c85ca419494a77dc2acfc82a2dd05940f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00313.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00313") -public class BenchmarkTest00313 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00313"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00314.java b/OWASP DATASET CLEANED/BenchmarkTest00314.java deleted file mode 100644 index 7e65d233d99ee9c70f2abeb89e214ddd19210239..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00314.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00314") -public class BenchmarkTest00314 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00314"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00315.java b/OWASP DATASET CLEANED/BenchmarkTest00315.java deleted file mode 100644 index db3dc07d36c4480f4213b3d01f1003ca4fc18d0d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00315.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00315") -public class BenchmarkTest00315 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00315"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map38775 = new java.util.HashMap(); - map38775.put("keyA-38775", "a_Value"); // put some stuff in the collection - map38775.put("keyB-38775", param); // put it in a collection - map38775.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map38775.get("keyB-38775"); // get it back out - bar = (String) map38775.get("keyA-38775"); // get safe value back out - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00316.java b/OWASP DATASET CLEANED/BenchmarkTest00316.java deleted file mode 100644 index f87ed77b58960d47867b923829b897ee5a248363..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00316.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00316") -public class BenchmarkTest00316 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00316"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a78780 = param; // assign - StringBuilder b78780 = new StringBuilder(a78780); // stick in stringbuilder - b78780.append(" SafeStuff"); // append some safe content - b78780.replace( - b78780.length() - "Chars".length(), - b78780.length(), - "Chars"); // replace some of the end content - java.util.HashMap map78780 = new java.util.HashMap(); - map78780.put("key78780", b78780.toString()); // put in a collection - String c78780 = (String) map78780.get("key78780"); // get it back out - String d78780 = c78780.substring(0, c78780.length() - 1); // extract most of it - String e78780 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d78780.getBytes()))); // B64 encode and decode it - String f78780 = e78780.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f78780); // reflection - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00317.java b/OWASP DATASET CLEANED/BenchmarkTest00317.java deleted file mode 100644 index 075a00a8dafa74600d30ca74de65f841143f6bb5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00317.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00317") -public class BenchmarkTest00317 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00317"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00318.java b/OWASP DATASET CLEANED/BenchmarkTest00318.java deleted file mode 100644 index 4817a4ecefef198a69992b0ade46227dca766347..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00318.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00318") -public class BenchmarkTest00318 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00318"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a30925 = param; // assign - StringBuilder b30925 = new StringBuilder(a30925); // stick in stringbuilder - b30925.append(" SafeStuff"); // append some safe content - b30925.replace( - b30925.length() - "Chars".length(), - b30925.length(), - "Chars"); // replace some of the end content - java.util.HashMap map30925 = new java.util.HashMap(); - map30925.put("key30925", b30925.toString()); // put in a collection - String c30925 = (String) map30925.get("key30925"); // get it back out - String d30925 = c30925.substring(0, c30925.length() - 1); // extract most of it - String e30925 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d30925.getBytes()))); // B64 encode and decode it - String f30925 = e30925.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g30925 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g30925); // reflection - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00319.java b/OWASP DATASET CLEANED/BenchmarkTest00319.java deleted file mode 100644 index 2323a15f2f08ca0aab7022f710fb4ef9b0d8d63e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00319.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00319") -public class BenchmarkTest00319 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00319"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00320.java b/OWASP DATASET CLEANED/BenchmarkTest00320.java deleted file mode 100644 index a58734f69ca633a63f9d44855fc7e63e3db1e678..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00320.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00320") -public class BenchmarkTest00320 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00320"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00321.java b/OWASP DATASET CLEANED/BenchmarkTest00321.java deleted file mode 100644 index f3ad553f8ed34fce28595c041b8de69d9c8003c9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00321.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00321") -public class BenchmarkTest00321 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00321"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00322.java b/OWASP DATASET CLEANED/BenchmarkTest00322.java deleted file mode 100644 index 8c15e38891b1363f765f95025fba46cc486f3ecf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00322.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00322") -public class BenchmarkTest00322 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00322"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map53101 = new java.util.HashMap(); - map53101.put("keyA-53101", "a_Value"); // put some stuff in the collection - map53101.put("keyB-53101", param); // put it in a collection - map53101.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map53101.get("keyB-53101"); // get it back out - bar = (String) map53101.get("keyA-53101"); // get safe value back out - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00323.java b/OWASP DATASET CLEANED/BenchmarkTest00323.java deleted file mode 100644 index 03cabc8e265b54e2b2496a783ef3038f87fa317d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00323.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00323") -public class BenchmarkTest00323 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00323"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00324.java b/OWASP DATASET CLEANED/BenchmarkTest00324.java deleted file mode 100644 index 16342fd3f0a7b5a22ee561321248ef9aa982b0f8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00324.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00324") -public class BenchmarkTest00324 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00324"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00325.java b/OWASP DATASET CLEANED/BenchmarkTest00325.java deleted file mode 100644 index 254205fe597d4bcacf0f92d06e81c6b76302811d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00325.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00325") -public class BenchmarkTest00325 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00325"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00326.java b/OWASP DATASET CLEANED/BenchmarkTest00326.java deleted file mode 100644 index 49baf35107a45f6ca4df7d0b38aafcb8c8ee7485..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00326.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00326") -public class BenchmarkTest00326 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00326"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00327.java b/OWASP DATASET CLEANED/BenchmarkTest00327.java deleted file mode 100644 index 4d07cfe5c7f6eb985dcdd0fb5c7b6537336664ad..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00327.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00327") -public class BenchmarkTest00327 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00327"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00328.java b/OWASP DATASET CLEANED/BenchmarkTest00328.java deleted file mode 100644 index 0e8575bac4be1f0742afe170318fe502be3277c8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00328.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00328") -public class BenchmarkTest00328 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00328"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00329.java b/OWASP DATASET CLEANED/BenchmarkTest00329.java deleted file mode 100644 index f4eeac686912c1fb9cdec28c256854c8ea19706e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00329.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00329") -public class BenchmarkTest00329 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00329"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00330.java b/OWASP DATASET CLEANED/BenchmarkTest00330.java deleted file mode 100644 index 6f2ead7d315eecf784be4c436da9754bd864ce97..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00330.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00330") -public class BenchmarkTest00330 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00330"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a55109 = param; // assign - StringBuilder b55109 = new StringBuilder(a55109); // stick in stringbuilder - b55109.append(" SafeStuff"); // append some safe content - b55109.replace( - b55109.length() - "Chars".length(), - b55109.length(), - "Chars"); // replace some of the end content - java.util.HashMap map55109 = new java.util.HashMap(); - map55109.put("key55109", b55109.toString()); // put in a collection - String c55109 = (String) map55109.get("key55109"); // get it back out - String d55109 = c55109.substring(0, c55109.length() - 1); // extract most of it - String e55109 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d55109.getBytes()))); // B64 encode and decode it - String f55109 = e55109.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g55109 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g55109); // reflection - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00331.java b/OWASP DATASET CLEANED/BenchmarkTest00331.java deleted file mode 100644 index d52c5e8d0a103cb4fd4cd15393ebb94ac3c1f4b0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00331.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00331") -public class BenchmarkTest00331 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00331"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map59781 = new java.util.HashMap(); - map59781.put("keyA-59781", "a_Value"); // put some stuff in the collection - map59781.put("keyB-59781", param); // put it in a collection - map59781.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map59781.get("keyB-59781"); // get it back out - bar = (String) map59781.get("keyA-59781"); // get safe value back out - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00332.java b/OWASP DATASET CLEANED/BenchmarkTest00332.java deleted file mode 100644 index 4fd8885bbc30e4fe1974dcdc396653b04e5ff910..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00332.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00332") -public class BenchmarkTest00332 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00332"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a40477 = param; // assign - StringBuilder b40477 = new StringBuilder(a40477); // stick in stringbuilder - b40477.append(" SafeStuff"); // append some safe content - b40477.replace( - b40477.length() - "Chars".length(), - b40477.length(), - "Chars"); // replace some of the end content - java.util.HashMap map40477 = new java.util.HashMap(); - map40477.put("key40477", b40477.toString()); // put in a collection - String c40477 = (String) map40477.get("key40477"); // get it back out - String d40477 = c40477.substring(0, c40477.length() - 1); // extract most of it - String e40477 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d40477.getBytes()))); // B64 encode and decode it - String f40477 = e40477.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g40477 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g40477); // reflection - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00333.java b/OWASP DATASET CLEANED/BenchmarkTest00333.java deleted file mode 100644 index 824bb8821f9fd109a3dcaf6d41638dd00e8d0a39..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00333.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00333") -public class BenchmarkTest00333 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00333"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00334.java b/OWASP DATASET CLEANED/BenchmarkTest00334.java deleted file mode 100644 index f4719854a49d9820d8d53d2ae24c8d19c630fa52..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00334.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00334") -public class BenchmarkTest00334 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00334"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a30608 = param; // assign - StringBuilder b30608 = new StringBuilder(a30608); // stick in stringbuilder - b30608.append(" SafeStuff"); // append some safe content - b30608.replace( - b30608.length() - "Chars".length(), - b30608.length(), - "Chars"); // replace some of the end content - java.util.HashMap map30608 = new java.util.HashMap(); - map30608.put("key30608", b30608.toString()); // put in a collection - String c30608 = (String) map30608.get("key30608"); // get it back out - String d30608 = c30608.substring(0, c30608.length() - 1); // extract most of it - String e30608 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d30608.getBytes()))); // B64 encode and decode it - String f30608 = e30608.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g30608 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g30608); // reflection - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00335.java b/OWASP DATASET CLEANED/BenchmarkTest00335.java deleted file mode 100644 index 20cbf1054092d16d8b9fa5dd45d6313fdb614997..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00335.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00335") -public class BenchmarkTest00335 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00335"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new int[] {1, 2}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00336.java b/OWASP DATASET CLEANED/BenchmarkTest00336.java deleted file mode 100644 index a82ade6005801007db2c94e01726014aa6859f81..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00336.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00336") -public class BenchmarkTest00336 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00336"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00337.java b/OWASP DATASET CLEANED/BenchmarkTest00337.java deleted file mode 100644 index dc77a80c7d26d767d285fd4a2765ddc4251fe565..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00337.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00337") -public class BenchmarkTest00337 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00337"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00338.java b/OWASP DATASET CLEANED/BenchmarkTest00338.java deleted file mode 100644 index 8c8d683c2e58671c1a6c9773c3f137956e171886..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00338.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00338") -public class BenchmarkTest00338 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00338"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00339.java b/OWASP DATASET CLEANED/BenchmarkTest00339.java deleted file mode 100644 index b68d7017712a3139f772a1e25b95e77e0f5165c8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00339.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00339") -public class BenchmarkTest00339 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00339"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00340.java b/OWASP DATASET CLEANED/BenchmarkTest00340.java deleted file mode 100644 index 53ff72bcb007d9bd795519b3b1ebb88b0dc91912..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00340.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00340") -public class BenchmarkTest00340 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00340"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00341.java b/OWASP DATASET CLEANED/BenchmarkTest00341.java deleted file mode 100644 index 7f071f2cf7bf53dc358ca499287f13b40f637185..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00341.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00341") -public class BenchmarkTest00341 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00341"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00342.java b/OWASP DATASET CLEANED/BenchmarkTest00342.java deleted file mode 100644 index 172e6cf83528fa901720dc1e3a1fcf2477246510..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00342.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00342") -public class BenchmarkTest00342 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00342"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00343.java b/OWASP DATASET CLEANED/BenchmarkTest00343.java deleted file mode 100644 index d472983b4b79985c0feb85c481a38c0b957e8a1e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00343.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00343") -public class BenchmarkTest00343 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00343"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00344.java b/OWASP DATASET CLEANED/BenchmarkTest00344.java deleted file mode 100644 index 105452493733210569dd9b0e754b2834c33aa644..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00344.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00344") -public class BenchmarkTest00344 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest00344"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00345.java b/OWASP DATASET CLEANED/BenchmarkTest00345.java deleted file mode 100644 index 10055500d73061e4c292bc0e0ffac2f4618385dd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00345.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00345") -public class BenchmarkTest00345 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.io.InputStream param = request.getInputStream(); - - java.io.InputStream bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00346.java b/OWASP DATASET CLEANED/BenchmarkTest00346.java deleted file mode 100644 index 46bf8989dbae107f65450ef579ab9a564e49156b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00346.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00346") -public class BenchmarkTest00346 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.io.InputStream param = request.getInputStream(); - - java.io.InputStream bar = param; - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00347.java b/OWASP DATASET CLEANED/BenchmarkTest00347.java deleted file mode 100644 index 4a855bab5d953fab874dca82e30e5c7431d210f0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00347.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00347") -public class BenchmarkTest00347 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.io.InputStream param = request.getInputStream(); - - java.io.InputStream bar = param; - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00348.java b/OWASP DATASET CLEANED/BenchmarkTest00348.java deleted file mode 100644 index 15c3af1d257387f6d5e6ad6fef49d9b2aa56b564..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00348.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00348") -public class BenchmarkTest00348 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.io.InputStream param = request.getInputStream(); - - java.io.InputStream bar = param; - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00349.java b/OWASP DATASET CLEANED/BenchmarkTest00349.java deleted file mode 100644 index ec0e26b1b757b4002fc46d0ed240a4c950c82a8f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00349.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00349") -public class BenchmarkTest00349 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.io.InputStream param = request.getInputStream(); - - java.io.InputStream bar = param; - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00350.java b/OWASP DATASET CLEANED/BenchmarkTest00350.java deleted file mode 100644 index bd9845395cf7abb00319cbdc5b4219ab92b745e6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00350.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00350") -public class BenchmarkTest00350 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00350"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map51742 = new java.util.HashMap(); - map51742.put("keyA-51742", "a_Value"); // put some stuff in the collection - map51742.put("keyB-51742", param); // put it in a collection - map51742.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map51742.get("keyB-51742"); // get it back out - bar = (String) map51742.get("keyA-51742"); // get safe value back out - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00351.java b/OWASP DATASET CLEANED/BenchmarkTest00351.java deleted file mode 100644 index 916d53f6e423d363f71093c24f7812b967f7ad2e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00351.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00351") -public class BenchmarkTest00351 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00351"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00352.java b/OWASP DATASET CLEANED/BenchmarkTest00352.java deleted file mode 100644 index d63e56161f7d8a0362e616c6b484ed1a02fc1dd6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00352.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00352") -public class BenchmarkTest00352 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00352"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a98424 = param; // assign - StringBuilder b98424 = new StringBuilder(a98424); // stick in stringbuilder - b98424.append(" SafeStuff"); // append some safe content - b98424.replace( - b98424.length() - "Chars".length(), - b98424.length(), - "Chars"); // replace some of the end content - java.util.HashMap map98424 = new java.util.HashMap(); - map98424.put("key98424", b98424.toString()); // put in a collection - String c98424 = (String) map98424.get("key98424"); // get it back out - String d98424 = c98424.substring(0, c98424.length() - 1); // extract most of it - String e98424 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d98424.getBytes()))); // B64 encode and decode it - String f98424 = e98424.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f98424); // reflection - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00353.java b/OWASP DATASET CLEANED/BenchmarkTest00353.java deleted file mode 100644 index b1223a47b7c338678ac6b46f8bf749e318d2e13a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00353.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00353") -public class BenchmarkTest00353 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00353"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map13001 = new java.util.HashMap(); - map13001.put("keyA-13001", "a_Value"); // put some stuff in the collection - map13001.put("keyB-13001", param); // put it in a collection - map13001.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map13001.get("keyB-13001"); // get it back out - bar = (String) map13001.get("keyA-13001"); // get safe value back out - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00354.java b/OWASP DATASET CLEANED/BenchmarkTest00354.java deleted file mode 100644 index 89b7102653e63b0aa81f40a612bf9c3d997db419..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00354.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00354") -public class BenchmarkTest00354 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00354"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00355.java b/OWASP DATASET CLEANED/BenchmarkTest00355.java deleted file mode 100644 index b1a12e58a2a8f656db6d32d1722ffce306e0da5b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00355.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00355") -public class BenchmarkTest00355 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00355"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a85622 = param; // assign - StringBuilder b85622 = new StringBuilder(a85622); // stick in stringbuilder - b85622.append(" SafeStuff"); // append some safe content - b85622.replace( - b85622.length() - "Chars".length(), - b85622.length(), - "Chars"); // replace some of the end content - java.util.HashMap map85622 = new java.util.HashMap(); - map85622.put("key85622", b85622.toString()); // put in a collection - String c85622 = (String) map85622.get("key85622"); // get it back out - String d85622 = c85622.substring(0, c85622.length() - 1); // extract most of it - String e85622 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d85622.getBytes()))); // B64 encode and decode it - String f85622 = e85622.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f85622); // reflection - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00356.java b/OWASP DATASET CLEANED/BenchmarkTest00356.java deleted file mode 100644 index e0a41e2d7178715724e363e24698054127ff6e0e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00356.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00356") -public class BenchmarkTest00356 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00356"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00357.java b/OWASP DATASET CLEANED/BenchmarkTest00357.java deleted file mode 100644 index ec5ff534ab52700a00d3c97ca3f4ff66c65b30ac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00357.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00357") -public class BenchmarkTest00357 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00357"); - if (param == null) param = ""; - - String bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00358.java b/OWASP DATASET CLEANED/BenchmarkTest00358.java deleted file mode 100644 index a2da251ff3304f9ccd17b545bb12328928ccc90f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00358.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00358") -public class BenchmarkTest00358 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00358"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00359.java b/OWASP DATASET CLEANED/BenchmarkTest00359.java deleted file mode 100644 index c98ad87389f0a9dc0d4b9ede8f9f8d7408c071ff..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00359.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00359") -public class BenchmarkTest00359 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00359"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00360.java b/OWASP DATASET CLEANED/BenchmarkTest00360.java deleted file mode 100644 index f2cc4b8f4dd2a53398618c9bed442835045c2ecc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00360.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00360") -public class BenchmarkTest00360 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00360"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00361.java b/OWASP DATASET CLEANED/BenchmarkTest00361.java deleted file mode 100644 index 5890cf6f9ef32fcb7514623e19f1d9e3c8333c31..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00361.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00361") -public class BenchmarkTest00361 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00361"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00362.java b/OWASP DATASET CLEANED/BenchmarkTest00362.java deleted file mode 100644 index 70edce338d1f04258614bcfb983ac27e1ded0d32..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00362.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00362") -public class BenchmarkTest00362 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00362"); - if (param == null) param = ""; - - String bar = param; - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00363.java b/OWASP DATASET CLEANED/BenchmarkTest00363.java deleted file mode 100644 index ad30df8903104123652ef964c203a98880b71473..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00363.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00363") -public class BenchmarkTest00363 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00363"); - if (param == null) param = ""; - - String bar = param; - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00364.java b/OWASP DATASET CLEANED/BenchmarkTest00364.java deleted file mode 100644 index fab65d32b438802d9d8fc0809387365826caabfd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00364.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00364") -public class BenchmarkTest00364 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00364"); - if (param == null) param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00365.java b/OWASP DATASET CLEANED/BenchmarkTest00365.java deleted file mode 100644 index fb8521a8b58f046e65f24452b3bcb51ccbdea48a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00365.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00365") -public class BenchmarkTest00365 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00365"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map10106 = new java.util.HashMap(); - map10106.put("keyA-10106", "a_Value"); // put some stuff in the collection - map10106.put("keyB-10106", param); // put it in a collection - map10106.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map10106.get("keyB-10106"); // get it back out - bar = (String) map10106.get("keyA-10106"); // get safe value back out - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00366.java b/OWASP DATASET CLEANED/BenchmarkTest00366.java deleted file mode 100644 index ad7b0bc7b0566ad0f3a0ef3b1a1ed32997b0c991..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00366.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00366") -public class BenchmarkTest00366 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00366"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00367.java b/OWASP DATASET CLEANED/BenchmarkTest00367.java deleted file mode 100644 index 5e765997fcb730bc51ea84b8908d7c54d1434376..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00367.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00367") -public class BenchmarkTest00367 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00367"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a12849 = param; // assign - StringBuilder b12849 = new StringBuilder(a12849); // stick in stringbuilder - b12849.append(" SafeStuff"); // append some safe content - b12849.replace( - b12849.length() - "Chars".length(), - b12849.length(), - "Chars"); // replace some of the end content - java.util.HashMap map12849 = new java.util.HashMap(); - map12849.put("key12849", b12849.toString()); // put in a collection - String c12849 = (String) map12849.get("key12849"); // get it back out - String d12849 = c12849.substring(0, c12849.length() - 1); // extract most of it - String e12849 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d12849.getBytes()))); // B64 encode and decode it - String f12849 = e12849.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g12849 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g12849); // reflection - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00368.java b/OWASP DATASET CLEANED/BenchmarkTest00368.java deleted file mode 100644 index c4c3bff5a97ceebf69f2c1d8fed7af7de6f60ece..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00368.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00368") -public class BenchmarkTest00368 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00368"); - if (param == null) param = ""; - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00369.java b/OWASP DATASET CLEANED/BenchmarkTest00369.java deleted file mode 100644 index a5df724ed6f1518f3ddd13d290b671af9064c9f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00369.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00369") -public class BenchmarkTest00369 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00369"); - if (param == null) param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00370.java b/OWASP DATASET CLEANED/BenchmarkTest00370.java deleted file mode 100644 index 5694998c1a9dd42745ee918585dd1017a9778e05..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00370.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00370") -public class BenchmarkTest00370 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00370"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00371.java b/OWASP DATASET CLEANED/BenchmarkTest00371.java deleted file mode 100644 index 1a5f46094197ec9928fbdac41111e740e542f9cb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00371.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00371") -public class BenchmarkTest00371 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00371"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00372.java b/OWASP DATASET CLEANED/BenchmarkTest00372.java deleted file mode 100644 index 466feff035f1066566dffb29552da0c6b71ff7f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00372.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00372") -public class BenchmarkTest00372 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00372"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00373.java b/OWASP DATASET CLEANED/BenchmarkTest00373.java deleted file mode 100644 index b21f7dd68bc9e23d8ff663aeb81f82cf7ec3365d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00373.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00373") -public class BenchmarkTest00373 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00373"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00374.java b/OWASP DATASET CLEANED/BenchmarkTest00374.java deleted file mode 100644 index 1aa66a8b6639f581e1413f790245a1d3eb6370bc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00374.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00374") -public class BenchmarkTest00374 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00374"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00375.java b/OWASP DATASET CLEANED/BenchmarkTest00375.java deleted file mode 100644 index d532f17f8535f7da4d97de72cae960b17586b0d7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00375.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00375") -public class BenchmarkTest00375 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00375"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00376.java b/OWASP DATASET CLEANED/BenchmarkTest00376.java deleted file mode 100644 index 94b41e15bd2f8928f9f438cc00f5525d7891dd5e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00376.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00376") -public class BenchmarkTest00376 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00376"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00377.java b/OWASP DATASET CLEANED/BenchmarkTest00377.java deleted file mode 100644 index 75ce7241ebb5ffc5ba40248ce650a78ed3b035a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00377.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00377") -public class BenchmarkTest00377 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00377"); - if (param == null) param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00378.java b/OWASP DATASET CLEANED/BenchmarkTest00378.java deleted file mode 100644 index 961b29bdb8f896ef8e9c8cd2d95ca91c40864008..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00378.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00378") -public class BenchmarkTest00378 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00378"); - if (param == null) param = ""; - - StringBuilder sbxyz85125 = new StringBuilder(param); - String bar = sbxyz85125.append("_SafeStuff").toString(); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00379.java b/OWASP DATASET CLEANED/BenchmarkTest00379.java deleted file mode 100644 index b3279cdf79b4fe07ec304f3d2a3619f570507c3e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00379.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00379") -public class BenchmarkTest00379 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00379"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a75704 = param; // assign - StringBuilder b75704 = new StringBuilder(a75704); // stick in stringbuilder - b75704.append(" SafeStuff"); // append some safe content - b75704.replace( - b75704.length() - "Chars".length(), - b75704.length(), - "Chars"); // replace some of the end content - java.util.HashMap map75704 = new java.util.HashMap(); - map75704.put("key75704", b75704.toString()); // put in a collection - String c75704 = (String) map75704.get("key75704"); // get it back out - String d75704 = c75704.substring(0, c75704.length() - 1); // extract most of it - String e75704 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d75704.getBytes()))); // B64 encode and decode it - String f75704 = e75704.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g75704 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g75704); // reflection - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00380.java b/OWASP DATASET CLEANED/BenchmarkTest00380.java deleted file mode 100644 index 22c404e4a7be0e13c26cb2d2febfcf9498573192..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00380.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00380") -public class BenchmarkTest00380 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00380"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00381.java b/OWASP DATASET CLEANED/BenchmarkTest00381.java deleted file mode 100644 index 5c365acfd879404a3c58d1aff4165225091aa44c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00381.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00381") -public class BenchmarkTest00381 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00381"); - if (param == null) param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00382.java b/OWASP DATASET CLEANED/BenchmarkTest00382.java deleted file mode 100644 index e78fb70326be92b940ba834196d6fee5f26b09df..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00382.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00382") -public class BenchmarkTest00382 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00382"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00383.java b/OWASP DATASET CLEANED/BenchmarkTest00383.java deleted file mode 100644 index bff684639a5a8e8142cccd41a696b99c8a86a231..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00383.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00383") -public class BenchmarkTest00383 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00383"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a2196 = param; // assign - StringBuilder b2196 = new StringBuilder(a2196); // stick in stringbuilder - b2196.append(" SafeStuff"); // append some safe content - b2196.replace( - b2196.length() - "Chars".length(), - b2196.length(), - "Chars"); // replace some of the end content - java.util.HashMap map2196 = new java.util.HashMap(); - map2196.put("key2196", b2196.toString()); // put in a collection - String c2196 = (String) map2196.get("key2196"); // get it back out - String d2196 = c2196.substring(0, c2196.length() - 1); // extract most of it - String e2196 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d2196.getBytes()))); // B64 encode and decode it - String f2196 = e2196.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f2196); // reflection - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00384.java b/OWASP DATASET CLEANED/BenchmarkTest00384.java deleted file mode 100644 index 241d3d938fa7d6e0614a2a11659fa4cf507a5b3a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00384.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00384") -public class BenchmarkTest00384 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00384"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00385.java b/OWASP DATASET CLEANED/BenchmarkTest00385.java deleted file mode 100644 index 04268892c7ba800e30e276cae02f75bcff642170..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00385.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00385") -public class BenchmarkTest00385 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00385"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a21475 = param; // assign - StringBuilder b21475 = new StringBuilder(a21475); // stick in stringbuilder - b21475.append(" SafeStuff"); // append some safe content - b21475.replace( - b21475.length() - "Chars".length(), - b21475.length(), - "Chars"); // replace some of the end content - java.util.HashMap map21475 = new java.util.HashMap(); - map21475.put("key21475", b21475.toString()); // put in a collection - String c21475 = (String) map21475.get("key21475"); // get it back out - String d21475 = c21475.substring(0, c21475.length() - 1); // extract most of it - String e21475 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d21475.getBytes()))); // B64 encode and decode it - String f21475 = e21475.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f21475); // reflection - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00386.java b/OWASP DATASET CLEANED/BenchmarkTest00386.java deleted file mode 100644 index 86171a88d6e9e1348ab4dc923c61c6a384dcd2c6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00386.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00386") -public class BenchmarkTest00386 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00386"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map8057 = new java.util.HashMap(); - map8057.put("keyA-8057", "a_Value"); // put some stuff in the collection - map8057.put("keyB-8057", param); // put it in a collection - map8057.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map8057.get("keyB-8057"); // get it back out - bar = (String) map8057.get("keyA-8057"); // get safe value back out - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00387.java b/OWASP DATASET CLEANED/BenchmarkTest00387.java deleted file mode 100644 index c8f85343d08064c0250db60511554c5b8421af10..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00387.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00387") -public class BenchmarkTest00387 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00387"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00388.java b/OWASP DATASET CLEANED/BenchmarkTest00388.java deleted file mode 100644 index b8bb389b41d7f6e1063d33445b57816fee1c2ace..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00388.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00388") -public class BenchmarkTest00388 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00388"); - if (param == null) param = ""; - - StringBuilder sbxyz30382 = new StringBuilder(param); - String bar = sbxyz30382.append("_SafeStuff").toString(); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00389.java b/OWASP DATASET CLEANED/BenchmarkTest00389.java deleted file mode 100644 index 7b99d89ce171c46e36f825f2db5e7b74a1ca1246..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00389.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00389") -public class BenchmarkTest00389 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00389"); - if (param == null) param = ""; - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00390.java b/OWASP DATASET CLEANED/BenchmarkTest00390.java deleted file mode 100644 index ae95854694781e0b60fcfee15f8e81e2c3ef7f6f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00390.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00390") -public class BenchmarkTest00390 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00390"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00391.java b/OWASP DATASET CLEANED/BenchmarkTest00391.java deleted file mode 100644 index 6fea39c60a8e6a79695748288af029d53b447d2d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00391.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00391") -public class BenchmarkTest00391 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00391"); - if (param == null) param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00392.java b/OWASP DATASET CLEANED/BenchmarkTest00392.java deleted file mode 100644 index 43a339449cb6ce527f93e6417cefc2655e662d33..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00392.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00392") -public class BenchmarkTest00392 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00392"); - if (param == null) param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz38384 = new StringBuilder(param); - bar = sbxyz38384.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00393.java b/OWASP DATASET CLEANED/BenchmarkTest00393.java deleted file mode 100644 index f16359f1246f0e6b3ce497b15a8c5467d79dfa12..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00393.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00393") -public class BenchmarkTest00393 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00393"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00394.java b/OWASP DATASET CLEANED/BenchmarkTest00394.java deleted file mode 100644 index d787192a3ca84dfb3f47487dfa23d6125dd005dc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00394.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00394") -public class BenchmarkTest00394 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00394"); - if (param == null) param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00395.java b/OWASP DATASET CLEANED/BenchmarkTest00395.java deleted file mode 100644 index 6fcc6512503ab52188943952195a51725313a6a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00395.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00395") -public class BenchmarkTest00395 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00395"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00396.java b/OWASP DATASET CLEANED/BenchmarkTest00396.java deleted file mode 100644 index 06054c3ea4c6bd038e3c95b5185fef97e1deea4b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00396.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00396") -public class BenchmarkTest00396 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00396"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00397.java b/OWASP DATASET CLEANED/BenchmarkTest00397.java deleted file mode 100644 index bdfb7af5cf7bab25685d18f35b553f28d1d98263..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00397.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00397") -public class BenchmarkTest00397 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00397"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00398.java b/OWASP DATASET CLEANED/BenchmarkTest00398.java deleted file mode 100644 index 024a017deb2c92dabae6afd3464e04233ed00f91..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00398.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00398") -public class BenchmarkTest00398 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00398"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map43631 = new java.util.HashMap(); - map43631.put("keyA-43631", "a_Value"); // put some stuff in the collection - map43631.put("keyB-43631", param); // put it in a collection - map43631.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map43631.get("keyB-43631"); // get it back out - bar = (String) map43631.get("keyA-43631"); // get safe value back out - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00399.java b/OWASP DATASET CLEANED/BenchmarkTest00399.java deleted file mode 100644 index 3f4673ec74bc2c30baca9dc2f8648b98183cc6f5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00399.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00399") -public class BenchmarkTest00399 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00399"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a78565 = param; // assign - StringBuilder b78565 = new StringBuilder(a78565); // stick in stringbuilder - b78565.append(" SafeStuff"); // append some safe content - b78565.replace( - b78565.length() - "Chars".length(), - b78565.length(), - "Chars"); // replace some of the end content - java.util.HashMap map78565 = new java.util.HashMap(); - map78565.put("key78565", b78565.toString()); // put in a collection - String c78565 = (String) map78565.get("key78565"); // get it back out - String d78565 = c78565.substring(0, c78565.length() - 1); // extract most of it - String e78565 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d78565.getBytes()))); // B64 encode and decode it - String f78565 = e78565.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g78565 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g78565); // reflection - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00400.java b/OWASP DATASET CLEANED/BenchmarkTest00400.java deleted file mode 100644 index 52644ac87927a00ad7fed0aaf59d89f5264d9ddd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00400.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00400") -public class BenchmarkTest00400 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00400"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00401.java b/OWASP DATASET CLEANED/BenchmarkTest00401.java deleted file mode 100644 index 7d584e38c80b3922dc0896553d2a642eb1f60135..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00401.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00401") -public class BenchmarkTest00401 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00401"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00402.java b/OWASP DATASET CLEANED/BenchmarkTest00402.java deleted file mode 100644 index de2327239214952d0ef03b3bf4cab1bd240011cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00402.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-00/BenchmarkTest00402") -public class BenchmarkTest00402 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00402"); - if (param == null) param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz11630 = new StringBuilder(param); - bar = sbxyz11630.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00403.java b/OWASP DATASET CLEANED/BenchmarkTest00403.java deleted file mode 100644 index 448abc6f7ab9bb1d5294192fa3580ea77030e6e0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00403.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00403") -public class BenchmarkTest00403 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00403"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00404.java b/OWASP DATASET CLEANED/BenchmarkTest00404.java deleted file mode 100644 index 58105bbd570e85b34484cb020b1b9375e9942a0e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00404.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00404") -public class BenchmarkTest00404 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00404"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00405.java b/OWASP DATASET CLEANED/BenchmarkTest00405.java deleted file mode 100644 index 21069fd2b3e6767c4e48b498da0825cc8c422467..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00405.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00405") -public class BenchmarkTest00405 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00405"); - if (param == null) param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00406.java b/OWASP DATASET CLEANED/BenchmarkTest00406.java deleted file mode 100644 index b74f6deed30caf22da2d5cd9624130f86a8420a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00406.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00406") -public class BenchmarkTest00406 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00406"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00407.java b/OWASP DATASET CLEANED/BenchmarkTest00407.java deleted file mode 100644 index faa3eec93e91c1e9e70f36dd48cfa68aba549c8a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00407.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00407") -public class BenchmarkTest00407 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00407"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00408.java b/OWASP DATASET CLEANED/BenchmarkTest00408.java deleted file mode 100644 index d9e22d402f2914062068265eb4af2515bc73148a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00408.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00408") -public class BenchmarkTest00408 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00408"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00409.java b/OWASP DATASET CLEANED/BenchmarkTest00409.java deleted file mode 100644 index 801c9b380290ab11b43781c4b4554e23d9418d34..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00409.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00409") -public class BenchmarkTest00409 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00409"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00410.java b/OWASP DATASET CLEANED/BenchmarkTest00410.java deleted file mode 100644 index 38903345381391726e587bfbe738eaa8234958c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00410.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00410") -public class BenchmarkTest00410 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00410"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map77851 = new java.util.HashMap(); - map77851.put("keyA-77851", "a_Value"); // put some stuff in the collection - map77851.put("keyB-77851", param); // put it in a collection - map77851.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map77851.get("keyB-77851"); // get it back out - bar = (String) map77851.get("keyA-77851"); // get safe value back out - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00411.java b/OWASP DATASET CLEANED/BenchmarkTest00411.java deleted file mode 100644 index 7056c37a82528de955ee745dc72b19b32dcf5e70..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00411.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00411") -public class BenchmarkTest00411 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00411"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a18204 = param; // assign - StringBuilder b18204 = new StringBuilder(a18204); // stick in stringbuilder - b18204.append(" SafeStuff"); // append some safe content - b18204.replace( - b18204.length() - "Chars".length(), - b18204.length(), - "Chars"); // replace some of the end content - java.util.HashMap map18204 = new java.util.HashMap(); - map18204.put("key18204", b18204.toString()); // put in a collection - String c18204 = (String) map18204.get("key18204"); // get it back out - String d18204 = c18204.substring(0, c18204.length() - 1); // extract most of it - String e18204 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d18204.getBytes()))); // B64 encode and decode it - String f18204 = e18204.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g18204 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g18204); // reflection - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00412.java b/OWASP DATASET CLEANED/BenchmarkTest00412.java deleted file mode 100644 index b0e9b14b27b65ba3730089d04a6b24c765d5d06c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00412.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00412") -public class BenchmarkTest00412 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00412"); - if (param == null) param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00413.java b/OWASP DATASET CLEANED/BenchmarkTest00413.java deleted file mode 100644 index 1d05f9d6a8bcc8b71274f23225040c8abece37b1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00413.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00413") -public class BenchmarkTest00413 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00413"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map27963 = new java.util.HashMap(); - map27963.put("keyA-27963", "a-Value"); // put some stuff in the collection - map27963.put("keyB-27963", param); // put it in a collection - map27963.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map27963.get("keyB-27963"); // get it back out - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00414.java b/OWASP DATASET CLEANED/BenchmarkTest00414.java deleted file mode 100644 index feb500fa5af252bd03b2502611cadeb23389bee1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00414.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00414") -public class BenchmarkTest00414 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00414"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00415.java b/OWASP DATASET CLEANED/BenchmarkTest00415.java deleted file mode 100644 index fd400566b8bd9e585ab7474d47ffec32c27c4f9e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00415.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00415") -public class BenchmarkTest00415 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00415"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00416.java b/OWASP DATASET CLEANED/BenchmarkTest00416.java deleted file mode 100644 index aa84001c3940977ae03e6b814461d04ae4ac5b1e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00416.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00416") -public class BenchmarkTest00416 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00416"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map22488 = new java.util.HashMap(); - map22488.put("keyA-22488", "a-Value"); // put some stuff in the collection - map22488.put("keyB-22488", param); // put it in a collection - map22488.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map22488.get("keyB-22488"); // get it back out - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00417.java b/OWASP DATASET CLEANED/BenchmarkTest00417.java deleted file mode 100644 index be1171f23c78679994e75f804daa7866eb1129c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00417.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00417") -public class BenchmarkTest00417 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00417"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00418.java b/OWASP DATASET CLEANED/BenchmarkTest00418.java deleted file mode 100644 index 0177ab48b32159f4013b0b1dcb5a3a5d3f494f57..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00418.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00418") -public class BenchmarkTest00418 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00418"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00419.java b/OWASP DATASET CLEANED/BenchmarkTest00419.java deleted file mode 100644 index fcdc1a586c7dc49cdad925c2baf38376b4eafc3f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00419.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00419") -public class BenchmarkTest00419 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00419"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00420.java b/OWASP DATASET CLEANED/BenchmarkTest00420.java deleted file mode 100644 index ee08fc6901ad04b0a17a434fe0ceb0279b382311..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00420.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00420") -public class BenchmarkTest00420 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00420"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00421.java b/OWASP DATASET CLEANED/BenchmarkTest00421.java deleted file mode 100644 index 2f05337f4c1decc47bbc26d50b67542a04ef7434..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00421.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00421") -public class BenchmarkTest00421 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00421"); - if (param == null) param = ""; - - String bar = param; - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00422.java b/OWASP DATASET CLEANED/BenchmarkTest00422.java deleted file mode 100644 index b87a76e8b04f136d6415448dd3db3f4a4f247c5b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00422.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00422") -public class BenchmarkTest00422 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00422"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00423.java b/OWASP DATASET CLEANED/BenchmarkTest00423.java deleted file mode 100644 index 0c59ef651712dab6d873b68cb230b0dc81081a4c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00423.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00423") -public class BenchmarkTest00423 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00423"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00424.java b/OWASP DATASET CLEANED/BenchmarkTest00424.java deleted file mode 100644 index ea27b1aa58dc5efec37ca6a77d02d9dd5b544f4e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00424.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00424") -public class BenchmarkTest00424 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00424"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00425.java b/OWASP DATASET CLEANED/BenchmarkTest00425.java deleted file mode 100644 index 0c18c6102510977d738455118d6b0da718dbef3d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00425.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00425") -public class BenchmarkTest00425 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00425"); - if (param == null) param = ""; - - StringBuilder sbxyz2192 = new StringBuilder(param); - String bar = sbxyz2192.append("_SafeStuff").toString(); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00426.java b/OWASP DATASET CLEANED/BenchmarkTest00426.java deleted file mode 100644 index 58c12146f9861ca394e1052bbd68cb5a4d49e34c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00426.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00426") -public class BenchmarkTest00426 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00426"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00427.java b/OWASP DATASET CLEANED/BenchmarkTest00427.java deleted file mode 100644 index e95c43e303c8ab04461b18e4591a667aef9652fc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00427.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00427") -public class BenchmarkTest00427 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00427"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a70670 = param; // assign - StringBuilder b70670 = new StringBuilder(a70670); // stick in stringbuilder - b70670.append(" SafeStuff"); // append some safe content - b70670.replace( - b70670.length() - "Chars".length(), - b70670.length(), - "Chars"); // replace some of the end content - java.util.HashMap map70670 = new java.util.HashMap(); - map70670.put("key70670", b70670.toString()); // put in a collection - String c70670 = (String) map70670.get("key70670"); // get it back out - String d70670 = c70670.substring(0, c70670.length() - 1); // extract most of it - String e70670 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d70670.getBytes()))); // B64 encode and decode it - String f70670 = e70670.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f70670); // reflection - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00428.java b/OWASP DATASET CLEANED/BenchmarkTest00428.java deleted file mode 100644 index ee8e851de3c6190b23436592b1cd8f1f48de7fec..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00428.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00428") -public class BenchmarkTest00428 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00428"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00429.java b/OWASP DATASET CLEANED/BenchmarkTest00429.java deleted file mode 100644 index c502ca7fc8d3bce2126dd54705e7d238915e9106..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00429.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00429") -public class BenchmarkTest00429 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00429"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00430.java b/OWASP DATASET CLEANED/BenchmarkTest00430.java deleted file mode 100644 index 76a7ed5a7f233f03eff7b2628b37d5e54b873c37..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00430.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00430") -public class BenchmarkTest00430 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00430"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00431.java b/OWASP DATASET CLEANED/BenchmarkTest00431.java deleted file mode 100644 index 5980ebd7915670afb85546f7ec6b0a98d5a273f2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00431.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00431") -public class BenchmarkTest00431 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00431"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00432.java b/OWASP DATASET CLEANED/BenchmarkTest00432.java deleted file mode 100644 index 10616e47296e8e1d3916ac50ec87c4b0e1672ab6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00432.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00432") -public class BenchmarkTest00432 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00432"); - if (param == null) param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00433.java b/OWASP DATASET CLEANED/BenchmarkTest00433.java deleted file mode 100644 index d9f3d917ace5580c482504a72c02e7442ca00419..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00433.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00433") -public class BenchmarkTest00433 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00433"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00434.java b/OWASP DATASET CLEANED/BenchmarkTest00434.java deleted file mode 100644 index c13ef88bc32ff5f82e0aaa310ba2ba390f52192c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00434.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00434") -public class BenchmarkTest00434 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00434"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00435.java b/OWASP DATASET CLEANED/BenchmarkTest00435.java deleted file mode 100644 index 8426d4b26f9b3cbe29fb4b5e92df4826340945b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00435.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00435") -public class BenchmarkTest00435 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00435"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map86691 = new java.util.HashMap(); - map86691.put("keyA-86691", "a-Value"); // put some stuff in the collection - map86691.put("keyB-86691", param); // put it in a collection - map86691.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map86691.get("keyB-86691"); // get it back out - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00436.java b/OWASP DATASET CLEANED/BenchmarkTest00436.java deleted file mode 100644 index 96437dcf6200103bdfca719f062207af88d28a8d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00436.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00436") -public class BenchmarkTest00436 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00436"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00437.java b/OWASP DATASET CLEANED/BenchmarkTest00437.java deleted file mode 100644 index f162be3075b57ac527975dc8afc134c98b2cab25..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00437.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00437") -public class BenchmarkTest00437 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00437"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00438.java b/OWASP DATASET CLEANED/BenchmarkTest00438.java deleted file mode 100644 index e50b930ea8e34150983e2d7b4f81985af0427f05..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00438.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00438") -public class BenchmarkTest00438 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00438"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00439.java b/OWASP DATASET CLEANED/BenchmarkTest00439.java deleted file mode 100644 index 2cd2a4966327a64c9023f7c3c916dbc33e2638ff..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00439.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00439") -public class BenchmarkTest00439 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00439"); - if (param == null) param = ""; - - String bar = param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00440.java b/OWASP DATASET CLEANED/BenchmarkTest00440.java deleted file mode 100644 index cc06f332ecae5d4bd952a52c7fac448c64f43331..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00440.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00440") -public class BenchmarkTest00440 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00440"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map67409 = new java.util.HashMap(); - map67409.put("keyA-67409", "a_Value"); // put some stuff in the collection - map67409.put("keyB-67409", param); // put it in a collection - map67409.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map67409.get("keyB-67409"); // get it back out - bar = (String) map67409.get("keyA-67409"); // get safe value back out - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00441.java b/OWASP DATASET CLEANED/BenchmarkTest00441.java deleted file mode 100644 index 630664e61eb39326d7b96a59db07785bf8a81821..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00441.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00441") -public class BenchmarkTest00441 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00441"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00442.java b/OWASP DATASET CLEANED/BenchmarkTest00442.java deleted file mode 100644 index b68ab0d5eddbaebd71ad297954c55c9f597883e6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00442.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest00442") -public class BenchmarkTest00442 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest00442"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00443.java b/OWASP DATASET CLEANED/BenchmarkTest00443.java deleted file mode 100644 index f5320276a436eff02218941f507aefd7ddce613b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00443.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00443") -public class BenchmarkTest00443 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00443"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00444.java b/OWASP DATASET CLEANED/BenchmarkTest00444.java deleted file mode 100644 index 4f752e8dc3c79ef7e198de0a4676a3dc5fdfcc2e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00444.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00444") -public class BenchmarkTest00444 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00444"); - if (values != null) param = values[0]; - } - - String bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00445.java b/OWASP DATASET CLEANED/BenchmarkTest00445.java deleted file mode 100644 index a1e6a0691fc73f21427ce2b1884574cd1ff03b54..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00445.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00445") -public class BenchmarkTest00445 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00445"); - if (values != null) param = values[0]; - } - - // Chain a bunch of propagators in sequence - String a98384 = param; // assign - StringBuilder b98384 = new StringBuilder(a98384); // stick in stringbuilder - b98384.append(" SafeStuff"); // append some safe content - b98384.replace( - b98384.length() - "Chars".length(), - b98384.length(), - "Chars"); // replace some of the end content - java.util.HashMap map98384 = new java.util.HashMap(); - map98384.put("key98384", b98384.toString()); // put in a collection - String c98384 = (String) map98384.get("key98384"); // get it back out - String d98384 = c98384.substring(0, c98384.length() - 1); // extract most of it - String e98384 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d98384.getBytes()))); // B64 encode and decode it - String f98384 = e98384.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f98384); // reflection - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00446.java b/OWASP DATASET CLEANED/BenchmarkTest00446.java deleted file mode 100644 index e95ac55586ace7163bc986b1484fa415efc2eec6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00446.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00446") -public class BenchmarkTest00446 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00446"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00447.java b/OWASP DATASET CLEANED/BenchmarkTest00447.java deleted file mode 100644 index 37b8636dd22f8d15f4b664ac943bcf3bb3144e01..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00447.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00447") -public class BenchmarkTest00447 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00447"); - if (values != null) param = values[0]; - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00448.java b/OWASP DATASET CLEANED/BenchmarkTest00448.java deleted file mode 100644 index 144b4e0f73f809faf8e2399a9e7a0252fd0fe71c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00448.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00448") -public class BenchmarkTest00448 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00448"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00449.java b/OWASP DATASET CLEANED/BenchmarkTest00449.java deleted file mode 100644 index 99ea57bc3e9f87cf8d49961c6da139a2395b611f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00449.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00449") -public class BenchmarkTest00449 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00449"); - if (values != null) param = values[0]; - } - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00450.java b/OWASP DATASET CLEANED/BenchmarkTest00450.java deleted file mode 100644 index 6fef7294181e5719df87f2982335b36cf394532a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00450.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00450") -public class BenchmarkTest00450 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00450"); - if (values != null) param = values[0]; - } - - // Chain a bunch of propagators in sequence - String a87006 = param; // assign - StringBuilder b87006 = new StringBuilder(a87006); // stick in stringbuilder - b87006.append(" SafeStuff"); // append some safe content - b87006.replace( - b87006.length() - "Chars".length(), - b87006.length(), - "Chars"); // replace some of the end content - java.util.HashMap map87006 = new java.util.HashMap(); - map87006.put("key87006", b87006.toString()); // put in a collection - String c87006 = (String) map87006.get("key87006"); // get it back out - String d87006 = c87006.substring(0, c87006.length() - 1); // extract most of it - String e87006 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d87006.getBytes()))); // B64 encode and decode it - String f87006 = e87006.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f87006); // reflection - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00451.java b/OWASP DATASET CLEANED/BenchmarkTest00451.java deleted file mode 100644 index 1026fded179f6e16dd0de353c35a584c976fc5cc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00451.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00451") -public class BenchmarkTest00451 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00451"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00452.java b/OWASP DATASET CLEANED/BenchmarkTest00452.java deleted file mode 100644 index cb18fa574578ca385454987987c9d5350f372516..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00452.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00452") -public class BenchmarkTest00452 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00452"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00453.java b/OWASP DATASET CLEANED/BenchmarkTest00453.java deleted file mode 100644 index 91885f681d04cf6c9ceaa7d3c73fcc2f7ce188ed..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00453.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00453") -public class BenchmarkTest00453 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00453"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00454.java b/OWASP DATASET CLEANED/BenchmarkTest00454.java deleted file mode 100644 index 1fba508ac9b9e8425ea3759e395021d3d99dc00a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00454.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00454") -public class BenchmarkTest00454 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00454"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00455.java b/OWASP DATASET CLEANED/BenchmarkTest00455.java deleted file mode 100644 index 14283f765f4dca189661059304a06f9618c41bbe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00455.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00455") -public class BenchmarkTest00455 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00455"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00456.java b/OWASP DATASET CLEANED/BenchmarkTest00456.java deleted file mode 100644 index 800dc8b1279904c9168e0b35dc2b35d90b0746b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00456.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00456") -public class BenchmarkTest00456 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00456"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map49381 = new java.util.HashMap(); - map49381.put("keyA-49381", "a-Value"); // put some stuff in the collection - map49381.put("keyB-49381", param); // put it in a collection - map49381.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map49381.get("keyB-49381"); // get it back out - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00457.java b/OWASP DATASET CLEANED/BenchmarkTest00457.java deleted file mode 100644 index 8fe5caf0060a9ea8b38cf996c7b5b392f009dc39..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00457.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00457") -public class BenchmarkTest00457 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00457"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00458.java b/OWASP DATASET CLEANED/BenchmarkTest00458.java deleted file mode 100644 index c2213df458ba7b5327f646100edc55c2df7eb424..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00458.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00458") -public class BenchmarkTest00458 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00458"); - if (values != null) param = values[0]; - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00459.java b/OWASP DATASET CLEANED/BenchmarkTest00459.java deleted file mode 100644 index 980b47bed106aa7b54a35113655cdf357d697ef9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00459.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00459") -public class BenchmarkTest00459 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00459"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00460.java b/OWASP DATASET CLEANED/BenchmarkTest00460.java deleted file mode 100644 index 6fb50e40e33a042ba3025e6a869880b79980c80c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00460.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00460") -public class BenchmarkTest00460 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00460"); - if (values != null) param = values[0]; - } - - // Chain a bunch of propagators in sequence - String a62588 = param; // assign - StringBuilder b62588 = new StringBuilder(a62588); // stick in stringbuilder - b62588.append(" SafeStuff"); // append some safe content - b62588.replace( - b62588.length() - "Chars".length(), - b62588.length(), - "Chars"); // replace some of the end content - java.util.HashMap map62588 = new java.util.HashMap(); - map62588.put("key62588", b62588.toString()); // put in a collection - String c62588 = (String) map62588.get("key62588"); // get it back out - String d62588 = c62588.substring(0, c62588.length() - 1); // extract most of it - String e62588 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d62588.getBytes()))); // B64 encode and decode it - String f62588 = e62588.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g62588 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g62588); // reflection - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00461.java b/OWASP DATASET CLEANED/BenchmarkTest00461.java deleted file mode 100644 index 98bb1390aaf54fe9074dcf57780a231fbe2fe1d4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00461.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00461") -public class BenchmarkTest00461 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00461"); - if (values != null) param = values[0]; - } - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00462.java b/OWASP DATASET CLEANED/BenchmarkTest00462.java deleted file mode 100644 index 23e53ca1dcb57e3f713c6a9a9d33e6667a97caba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00462.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00462") -public class BenchmarkTest00462 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00462"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00463.java b/OWASP DATASET CLEANED/BenchmarkTest00463.java deleted file mode 100644 index f74ba7c9365daf82217e638e8fecb5606c66122c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00463.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00463") -public class BenchmarkTest00463 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00463"); - if (values != null) param = values[0]; - } - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00464.java b/OWASP DATASET CLEANED/BenchmarkTest00464.java deleted file mode 100644 index 7e9d8e90e46cd21eed460c52d3781fea003c375b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00464.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00464") -public class BenchmarkTest00464 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00464"); - if (values != null) param = values[0]; - } - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00465.java b/OWASP DATASET CLEANED/BenchmarkTest00465.java deleted file mode 100644 index e0fcd19d288e8cdb2cf1d92e22271bb77cd8219e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00465.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00465") -public class BenchmarkTest00465 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00465"); - if (values != null) param = values[0]; - } - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00466.java b/OWASP DATASET CLEANED/BenchmarkTest00466.java deleted file mode 100644 index fed57333f376b05a1c3afd69b536e6149805fe76..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00466.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00466") -public class BenchmarkTest00466 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00466"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map46344 = new java.util.HashMap(); - map46344.put("keyA-46344", "a-Value"); // put some stuff in the collection - map46344.put("keyB-46344", param); // put it in a collection - map46344.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map46344.get("keyB-46344"); // get it back out - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00467.java b/OWASP DATASET CLEANED/BenchmarkTest00467.java deleted file mode 100644 index de85fdc2a96e5149b3972877235022e62e8a48d3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00467.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00467") -public class BenchmarkTest00467 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00467"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map88136 = new java.util.HashMap(); - map88136.put("keyA-88136", "a-Value"); // put some stuff in the collection - map88136.put("keyB-88136", param); // put it in a collection - map88136.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map88136.get("keyB-88136"); // get it back out - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00468.java b/OWASP DATASET CLEANED/BenchmarkTest00468.java deleted file mode 100644 index 299d881d0570250a2376883fd433540c180079b0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00468.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00468") -public class BenchmarkTest00468 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00468"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map50379 = new java.util.HashMap(); - map50379.put("keyA-50379", "a_Value"); // put some stuff in the collection - map50379.put("keyB-50379", param); // put it in a collection - map50379.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map50379.get("keyB-50379"); // get it back out - bar = (String) map50379.get("keyA-50379"); // get safe value back out - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00469.java b/OWASP DATASET CLEANED/BenchmarkTest00469.java deleted file mode 100644 index 66c152e0fc13a1f7a75c14364063e3293385d3b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00469.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00469") -public class BenchmarkTest00469 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00469"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00470.java b/OWASP DATASET CLEANED/BenchmarkTest00470.java deleted file mode 100644 index 792a80ecf1bbd05eefca7ecf0ba997685a13e28e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00470.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00470") -public class BenchmarkTest00470 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00470"); - if (values != null) param = values[0]; - } - - // Chain a bunch of propagators in sequence - String a1504 = param; // assign - StringBuilder b1504 = new StringBuilder(a1504); // stick in stringbuilder - b1504.append(" SafeStuff"); // append some safe content - b1504.replace( - b1504.length() - "Chars".length(), - b1504.length(), - "Chars"); // replace some of the end content - java.util.HashMap map1504 = new java.util.HashMap(); - map1504.put("key1504", b1504.toString()); // put in a collection - String c1504 = (String) map1504.get("key1504"); // get it back out - String d1504 = c1504.substring(0, c1504.length() - 1); // extract most of it - String e1504 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d1504.getBytes()))); // B64 encode and decode it - String f1504 = e1504.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g1504 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g1504); // reflection - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00471.java b/OWASP DATASET CLEANED/BenchmarkTest00471.java deleted file mode 100644 index bb14300a0d2186ac32bf1d738e80351e0c77799b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00471.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00471") -public class BenchmarkTest00471 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00471"); - if (values != null) param = values[0]; - } - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00472.java b/OWASP DATASET CLEANED/BenchmarkTest00472.java deleted file mode 100644 index 55a891d9ce5ef3b9771b8ac5a0faf2b63601d267..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00472.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00472") -public class BenchmarkTest00472 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00472"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00473.java b/OWASP DATASET CLEANED/BenchmarkTest00473.java deleted file mode 100644 index f4e657825d8a91081dfa4507901e6c07d9853baa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00473.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00473") -public class BenchmarkTest00473 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00473"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00474.java b/OWASP DATASET CLEANED/BenchmarkTest00474.java deleted file mode 100644 index 9932e4e4bf6b8e6ec9c749c2c9f5ce5d3b87b379..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00474.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00474") -public class BenchmarkTest00474 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00474"); - if (values != null) param = values[0]; - } - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00475.java b/OWASP DATASET CLEANED/BenchmarkTest00475.java deleted file mode 100644 index 5a0095342f95d0d657e47251dd9c1699ac816989..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00475.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00475") -public class BenchmarkTest00475 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00475"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00476.java b/OWASP DATASET CLEANED/BenchmarkTest00476.java deleted file mode 100644 index 2ae14763d58c015839ba8943be85d8f7f17ef75c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00476.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00476") -public class BenchmarkTest00476 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00476"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00477.java b/OWASP DATASET CLEANED/BenchmarkTest00477.java deleted file mode 100644 index 43d6189bb96e1d9b0b90e6560d8ee79b1b9fc8df..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00477.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00477") -public class BenchmarkTest00477 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00477"); - if (values != null) param = values[0]; - } - - StringBuilder sbxyz54686 = new StringBuilder(param); - String bar = sbxyz54686.append("_SafeStuff").toString(); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00478.java b/OWASP DATASET CLEANED/BenchmarkTest00478.java deleted file mode 100644 index cbb1e7801db2a7d5fcc111b48506f7ea8e20bfd1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00478.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00478") -public class BenchmarkTest00478 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00478"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00479.java b/OWASP DATASET CLEANED/BenchmarkTest00479.java deleted file mode 100644 index 119fa0eb4ec36e46bebf8a10ff73b61fe0037737..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00479.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00479") -public class BenchmarkTest00479 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00479"); - if (values != null) param = values[0]; - } - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00480.java b/OWASP DATASET CLEANED/BenchmarkTest00480.java deleted file mode 100644 index 2cc9fd10dff37465210e1325e015dde388de7e25..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00480.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00480") -public class BenchmarkTest00480 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00480"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00481.java b/OWASP DATASET CLEANED/BenchmarkTest00481.java deleted file mode 100644 index 03277a1bd2d81ad89ac618d655283d07c2177260..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00481.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00481") -public class BenchmarkTest00481 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00481"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00482.java b/OWASP DATASET CLEANED/BenchmarkTest00482.java deleted file mode 100644 index bd3979354b3a59849cf941ee68253a11125c143d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00482.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00482") -public class BenchmarkTest00482 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00482"); - if (values != null) param = values[0]; - } - - String bar = param; - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00483.java b/OWASP DATASET CLEANED/BenchmarkTest00483.java deleted file mode 100644 index 6e2726d93b8f3e9ff1fb786a43eb68359f240d84..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00483.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00483") -public class BenchmarkTest00483 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00483"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00484.java b/OWASP DATASET CLEANED/BenchmarkTest00484.java deleted file mode 100644 index 278e688416ddf93c7aa7c0459c64c8186affff0d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00484.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00484") -public class BenchmarkTest00484 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00484"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00485.java b/OWASP DATASET CLEANED/BenchmarkTest00485.java deleted file mode 100644 index 80ea4ede8e3613b3eae524be660a1784603cfb3d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00485.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00485") -public class BenchmarkTest00485 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00485"); - if (values != null) param = values[0]; - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00486.java b/OWASP DATASET CLEANED/BenchmarkTest00486.java deleted file mode 100644 index 18623b68c8196786da4a5ddfc61ba66251728dbf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00486.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00486") -public class BenchmarkTest00486 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00486"); - if (values != null) param = values[0]; - } - - String bar = param; - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00487.java b/OWASP DATASET CLEANED/BenchmarkTest00487.java deleted file mode 100644 index 5c6cf0b277322981d6d422145bb184aa83f38d77..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00487.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00487") -public class BenchmarkTest00487 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00487"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map10732 = new java.util.HashMap(); - map10732.put("keyA-10732", "a-Value"); // put some stuff in the collection - map10732.put("keyB-10732", param); // put it in a collection - map10732.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map10732.get("keyB-10732"); // get it back out - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00488.java b/OWASP DATASET CLEANED/BenchmarkTest00488.java deleted file mode 100644 index 44e4755c7aca9f458ef06b2b541977ba09da2b6f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00488.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00488") -public class BenchmarkTest00488 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00488"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00489.java b/OWASP DATASET CLEANED/BenchmarkTest00489.java deleted file mode 100644 index 97882bfd302cadd04ba7452556efea2d6f68d82c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00489.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00489") -public class BenchmarkTest00489 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00489"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map25864 = new java.util.HashMap(); - map25864.put("keyA-25864", "a-Value"); // put some stuff in the collection - map25864.put("keyB-25864", param); // put it in a collection - map25864.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map25864.get("keyB-25864"); // get it back out - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00490.java b/OWASP DATASET CLEANED/BenchmarkTest00490.java deleted file mode 100644 index dec673c7eb04aad6d91c83a8208406965ba9b72a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00490.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00490") -public class BenchmarkTest00490 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00490"); - if (values != null) param = values[0]; - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00491.java b/OWASP DATASET CLEANED/BenchmarkTest00491.java deleted file mode 100644 index 6aed9f3b0e8fe3b753252a98aa016e559789e591..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00491.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00491") -public class BenchmarkTest00491 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00491"); - if (values != null) param = values[0]; - } - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz92030 = new StringBuilder(param); - bar = sbxyz92030.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00492.java b/OWASP DATASET CLEANED/BenchmarkTest00492.java deleted file mode 100644 index 52ed0a662a64ca102629b655b4f0ff5c2b8e857f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00492.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00492") -public class BenchmarkTest00492 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00492"); - if (values != null) param = values[0]; - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00493.java b/OWASP DATASET CLEANED/BenchmarkTest00493.java deleted file mode 100644 index cb82b58df2d4fbd381f69a7bd7f33d6442a8563b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00493.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00493") -public class BenchmarkTest00493 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00493"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map8943 = new java.util.HashMap(); - map8943.put("keyA-8943", "a_Value"); // put some stuff in the collection - map8943.put("keyB-8943", param); // put it in a collection - map8943.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map8943.get("keyB-8943"); // get it back out - bar = (String) map8943.get("keyA-8943"); // get safe value back out - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00494.java b/OWASP DATASET CLEANED/BenchmarkTest00494.java deleted file mode 100644 index 453857182407caf1049925d98f8228efa8de35ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00494.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00494") -public class BenchmarkTest00494 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00494"); - if (values != null) param = values[0]; - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00495.java b/OWASP DATASET CLEANED/BenchmarkTest00495.java deleted file mode 100644 index 9c03a1bf3cd8a396007c7c28a25bfa967d1e47ba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00495.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00495") -public class BenchmarkTest00495 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00495"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00496.java b/OWASP DATASET CLEANED/BenchmarkTest00496.java deleted file mode 100644 index 0227346cb1744337c754173c953bdc8cbe4dda21..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00496.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00496") -public class BenchmarkTest00496 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00496"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00497.java b/OWASP DATASET CLEANED/BenchmarkTest00497.java deleted file mode 100644 index 10dabf6245e0df687cf96f73a3d68b299e2b6ffc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00497.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00497") -public class BenchmarkTest00497 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00497"); - if (values != null) param = values[0]; - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00498.java b/OWASP DATASET CLEANED/BenchmarkTest00498.java deleted file mode 100644 index ed23b927eda9af6a3d71551e50eae916ff823eb4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00498.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00498") -public class BenchmarkTest00498 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00498"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00499.java b/OWASP DATASET CLEANED/BenchmarkTest00499.java deleted file mode 100644 index 51a1433178ff3f244ff23b0593c54b2da37969b3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00499.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00499") -public class BenchmarkTest00499 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00499"); - if (values != null) param = values[0]; - } - - String bar = param; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00500.java b/OWASP DATASET CLEANED/BenchmarkTest00500.java deleted file mode 100644 index a4680882cfa56e58b04a2bf785867269b5539417..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00500.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00500") -public class BenchmarkTest00500 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00500"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00501.java b/OWASP DATASET CLEANED/BenchmarkTest00501.java deleted file mode 100644 index 0a9fa86e2252769c93012d525bcd2b73b9d6d031..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00501.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00501") -public class BenchmarkTest00501 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00501"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00502.java b/OWASP DATASET CLEANED/BenchmarkTest00502.java deleted file mode 100644 index dc631cbd71a924deede2b79b74658501a3361e41..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00502.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00502") -public class BenchmarkTest00502 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00502"); - if (values != null) param = values[0]; - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00503.java b/OWASP DATASET CLEANED/BenchmarkTest00503.java deleted file mode 100644 index 9a9404f2993060c14c9cf201a3f17026f2ca3d09..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00503.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00503") -public class BenchmarkTest00503 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00503"); - if (values != null) param = values[0]; - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00504.java b/OWASP DATASET CLEANED/BenchmarkTest00504.java deleted file mode 100644 index 1d1cf926c9f9effd637f2d0bfae8e9d17595ecf5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00504.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00504") -public class BenchmarkTest00504 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00504"); - if (values != null) param = values[0]; - } - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00505.java b/OWASP DATASET CLEANED/BenchmarkTest00505.java deleted file mode 100644 index 0bf369bb8e5ba24512ad74321c67487f714a925a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00505.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00505") -public class BenchmarkTest00505 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00505"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map67557 = new java.util.HashMap(); - map67557.put("keyA-67557", "a-Value"); // put some stuff in the collection - map67557.put("keyB-67557", param); // put it in a collection - map67557.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map67557.get("keyB-67557"); // get it back out - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00506.java b/OWASP DATASET CLEANED/BenchmarkTest00506.java deleted file mode 100644 index 023e17a3e5ef426b542d31775d9fc2d6df3d37a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00506.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00506") -public class BenchmarkTest00506 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00506"); - if (values != null) param = values[0]; - } - - // Chain a bunch of propagators in sequence - String a5528 = param; // assign - StringBuilder b5528 = new StringBuilder(a5528); // stick in stringbuilder - b5528.append(" SafeStuff"); // append some safe content - b5528.replace( - b5528.length() - "Chars".length(), - b5528.length(), - "Chars"); // replace some of the end content - java.util.HashMap map5528 = new java.util.HashMap(); - map5528.put("key5528", b5528.toString()); // put in a collection - String c5528 = (String) map5528.get("key5528"); // get it back out - String d5528 = c5528.substring(0, c5528.length() - 1); // extract most of it - String e5528 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d5528.getBytes()))); // B64 encode and decode it - String f5528 = e5528.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g5528 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g5528); // reflection - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00507.java b/OWASP DATASET CLEANED/BenchmarkTest00507.java deleted file mode 100644 index 3cbb17cc111864071c01997165a4bd4a2f9b9a66..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00507.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00507") -public class BenchmarkTest00507 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00507"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00508.java b/OWASP DATASET CLEANED/BenchmarkTest00508.java deleted file mode 100644 index 2be02f7bc8d98b42ba5f30a649387836ce89e449..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00508.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00508") -public class BenchmarkTest00508 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00508"); - if (values != null) param = values[0]; - } - - StringBuilder sbxyz10446 = new StringBuilder(param); - String bar = sbxyz10446.append("_SafeStuff").toString(); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00509.java b/OWASP DATASET CLEANED/BenchmarkTest00509.java deleted file mode 100644 index 4e452ae0f72dd678de9fb180fa73f1d30fce49ae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00509.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00509") -public class BenchmarkTest00509 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00509"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map94841 = new java.util.HashMap(); - map94841.put("keyA-94841", "a_Value"); // put some stuff in the collection - map94841.put("keyB-94841", param); // put it in a collection - map94841.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map94841.get("keyB-94841"); // get it back out - bar = (String) map94841.get("keyA-94841"); // get safe value back out - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00510.java b/OWASP DATASET CLEANED/BenchmarkTest00510.java deleted file mode 100644 index 7267eabd86479e44498a2186190dab810edfd428..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00510.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-00/BenchmarkTest00510") -public class BenchmarkTest00510 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00510"); - if (values != null) param = values[0]; - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00511.java b/OWASP DATASET CLEANED/BenchmarkTest00511.java deleted file mode 100644 index bbb216be6da43130ceb490581120ae0ead7d626e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00511.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00511") -public class BenchmarkTest00511 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00511"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map94915 = new java.util.HashMap(); - map94915.put("keyA-94915", "a_Value"); // put some stuff in the collection - map94915.put("keyB-94915", param); // put it in a collection - map94915.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map94915.get("keyB-94915"); // get it back out - bar = (String) map94915.get("keyA-94915"); // get safe value back out - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00512.java b/OWASP DATASET CLEANED/BenchmarkTest00512.java deleted file mode 100644 index 60b0cb34dd0b11f03e6bc99dbac1c2b52060e1d8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00512.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00512") -public class BenchmarkTest00512 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00512"); - if (values != null) param = values[0]; - } - - String bar = param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00513.java b/OWASP DATASET CLEANED/BenchmarkTest00513.java deleted file mode 100644 index 75bcc001594d07e92eb96a0a102b8c40f99875a0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00513.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00513") -public class BenchmarkTest00513 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00513"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map63945 = new java.util.HashMap(); - map63945.put("keyA-63945", "a_Value"); // put some stuff in the collection - map63945.put("keyB-63945", param); // put it in a collection - map63945.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map63945.get("keyB-63945"); // get it back out - bar = (String) map63945.get("keyA-63945"); // get safe value back out - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00514.java b/OWASP DATASET CLEANED/BenchmarkTest00514.java deleted file mode 100644 index 773c7280d5d958737237ad4077b0d22691a7ea48..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00514.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00514") -public class BenchmarkTest00514 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00514"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00515.java b/OWASP DATASET CLEANED/BenchmarkTest00515.java deleted file mode 100644 index 72806247f37b81784964ad5a8f6c722f4bc9d7f2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00515.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00515") -public class BenchmarkTest00515 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00515"); - if (values != null) param = values[0]; - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00516.java b/OWASP DATASET CLEANED/BenchmarkTest00516.java deleted file mode 100644 index f9091b05acc8775e790d2b6bb751515278bf99f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00516.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00516") -public class BenchmarkTest00516 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00516"); - if (values != null) param = values[0]; - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00517.java b/OWASP DATASET CLEANED/BenchmarkTest00517.java deleted file mode 100644 index 192af9e3a391e8b6188883fb8e96b6a7aafcc1a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00517.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00517") -public class BenchmarkTest00517 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00517"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00518.java b/OWASP DATASET CLEANED/BenchmarkTest00518.java deleted file mode 100644 index da6da56bd6519a3e47d25ea0b87baa211a1fd403..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00518.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00518") -public class BenchmarkTest00518 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00518"); - if (values != null) param = values[0]; - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00519.java b/OWASP DATASET CLEANED/BenchmarkTest00519.java deleted file mode 100644 index 1f3cd3dd5917880cddf13d8a3b8b5fa784d781f3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00519.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00519") -public class BenchmarkTest00519 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00519"); - if (values != null) param = values[0]; - } - - String bar = "safe!"; - java.util.HashMap map30190 = new java.util.HashMap(); - map30190.put("keyA-30190", "a_Value"); // put some stuff in the collection - map30190.put("keyB-30190", param); // put it in a collection - map30190.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map30190.get("keyB-30190"); // get it back out - bar = (String) map30190.get("keyA-30190"); // get safe value back out - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00520.java b/OWASP DATASET CLEANED/BenchmarkTest00520.java deleted file mode 100644 index 1687e5245a6daba7d9335d432d8c168a42cb44e4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00520.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest00520") -public class BenchmarkTest00520 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest00520"); - if (values != null) param = values[0]; - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00521.java b/OWASP DATASET CLEANED/BenchmarkTest00521.java deleted file mode 100644 index 42b9e4ff3fcb4715290abff4d782b4415c59771d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00521.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00521") -public class BenchmarkTest00521 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00521")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00522.java b/OWASP DATASET CLEANED/BenchmarkTest00522.java deleted file mode 100644 index d059b9b400c23c8df908d74298525d4534e3ba6a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00522.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00522") -public class BenchmarkTest00522 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00522")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00523.java b/OWASP DATASET CLEANED/BenchmarkTest00523.java deleted file mode 100644 index 310c1ba46f399f4bd7133b7b3ea9e223ee476169..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00523.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00523") -public class BenchmarkTest00523 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00523")) { - param = name; - flag = false; - } - } - } - } - - // Chain a bunch of propagators in sequence - String a87760 = param; // assign - StringBuilder b87760 = new StringBuilder(a87760); // stick in stringbuilder - b87760.append(" SafeStuff"); // append some safe content - b87760.replace( - b87760.length() - "Chars".length(), - b87760.length(), - "Chars"); // replace some of the end content - java.util.HashMap map87760 = new java.util.HashMap(); - map87760.put("key87760", b87760.toString()); // put in a collection - String c87760 = (String) map87760.get("key87760"); // get it back out - String d87760 = c87760.substring(0, c87760.length() - 1); // extract most of it - String e87760 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d87760.getBytes()))); // B64 encode and decode it - String f87760 = e87760.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g87760 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g87760); // reflection - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00524.java b/OWASP DATASET CLEANED/BenchmarkTest00524.java deleted file mode 100644 index 3bd22d60f5b6054ffdd59b52a8c43fd0533f127e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00524.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00524") -public class BenchmarkTest00524 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00524")) { - param = name; - flag = false; - } - } - } - } - - // Chain a bunch of propagators in sequence - String a18964 = param; // assign - StringBuilder b18964 = new StringBuilder(a18964); // stick in stringbuilder - b18964.append(" SafeStuff"); // append some safe content - b18964.replace( - b18964.length() - "Chars".length(), - b18964.length(), - "Chars"); // replace some of the end content - java.util.HashMap map18964 = new java.util.HashMap(); - map18964.put("key18964", b18964.toString()); // put in a collection - String c18964 = (String) map18964.get("key18964"); // get it back out - String d18964 = c18964.substring(0, c18964.length() - 1); // extract most of it - String e18964 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d18964.getBytes()))); // B64 encode and decode it - String f18964 = e18964.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f18964); // reflection - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00525.java b/OWASP DATASET CLEANED/BenchmarkTest00525.java deleted file mode 100644 index 2a672370ab127a2d5cd4afbeae5b00830da90662..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00525.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00525") -public class BenchmarkTest00525 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00525")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00526.java b/OWASP DATASET CLEANED/BenchmarkTest00526.java deleted file mode 100644 index 2870f0f235004d0359411ba08089d4468a27b1de..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00526.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00526") -public class BenchmarkTest00526 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00526")) { - param = name; - flag = false; - } - } - } - } - - String bar = param; - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00527.java b/OWASP DATASET CLEANED/BenchmarkTest00527.java deleted file mode 100644 index 1a18a4b73e123d79afc97ab7c8e5f603266f6e22..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00527.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00527") -public class BenchmarkTest00527 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00527")) { - param = name; - flag = false; - } - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00528.java b/OWASP DATASET CLEANED/BenchmarkTest00528.java deleted file mode 100644 index 9104f14854a78d56f7e01047c85bfa95d7ec1585..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00528.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00528") -public class BenchmarkTest00528 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00528")) { - param = name; - flag = false; - } - } - } - } - - String bar = "safe!"; - java.util.HashMap map6751 = new java.util.HashMap(); - map6751.put("keyA-6751", "a-Value"); // put some stuff in the collection - map6751.put("keyB-6751", param); // put it in a collection - map6751.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map6751.get("keyB-6751"); // get it back out - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00529.java b/OWASP DATASET CLEANED/BenchmarkTest00529.java deleted file mode 100644 index d2e2f6af2a2b5378f0749457afef5ce672d07d42..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00529.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00529") -public class BenchmarkTest00529 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00529")) { - param = name; - flag = false; - } - } - } - } - - String bar = param; - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00530.java b/OWASP DATASET CLEANED/BenchmarkTest00530.java deleted file mode 100644 index 88b7a2f88bcacb1aaf7e4436c8fc88af07adfd6b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00530.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00530") -public class BenchmarkTest00530 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00530")) { - param = name; - flag = false; - } - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00531.java b/OWASP DATASET CLEANED/BenchmarkTest00531.java deleted file mode 100644 index 6fda87af7ac1d5a9911c25c3eaf3871b6c7ae60f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00531.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00531") -public class BenchmarkTest00531 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00531")) { - param = name; - flag = false; - } - } - } - } - - String bar = "safe!"; - java.util.HashMap map38098 = new java.util.HashMap(); - map38098.put("keyA-38098", "a-Value"); // put some stuff in the collection - map38098.put("keyB-38098", param); // put it in a collection - map38098.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map38098.get("keyB-38098"); // get it back out - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00532.java b/OWASP DATASET CLEANED/BenchmarkTest00532.java deleted file mode 100644 index 0dd2ef43dfdc4bad40c8e5424c7996fcddc513b7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00532.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00532") -public class BenchmarkTest00532 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00532")) { - param = name; - flag = false; - } - } - } - } - - // Chain a bunch of propagators in sequence - String a25409 = param; // assign - StringBuilder b25409 = new StringBuilder(a25409); // stick in stringbuilder - b25409.append(" SafeStuff"); // append some safe content - b25409.replace( - b25409.length() - "Chars".length(), - b25409.length(), - "Chars"); // replace some of the end content - java.util.HashMap map25409 = new java.util.HashMap(); - map25409.put("key25409", b25409.toString()); // put in a collection - String c25409 = (String) map25409.get("key25409"); // get it back out - String d25409 = c25409.substring(0, c25409.length() - 1); // extract most of it - String e25409 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d25409.getBytes()))); // B64 encode and decode it - String f25409 = e25409.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f25409); // reflection - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00533.java b/OWASP DATASET CLEANED/BenchmarkTest00533.java deleted file mode 100644 index 8daec3b0c855ffb3fe2a25d7b37dc54165425b03..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00533.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00533") -public class BenchmarkTest00533 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00533")) { - param = name; - flag = false; - } - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00534.java b/OWASP DATASET CLEANED/BenchmarkTest00534.java deleted file mode 100644 index 5ead2a84535b34a252852f21723a7ab0a83c002a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00534.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00534") -public class BenchmarkTest00534 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00534")) { - param = name; - flag = false; - } - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00535.java b/OWASP DATASET CLEANED/BenchmarkTest00535.java deleted file mode 100644 index 796bce7e7998f47078cade6ce95ec186ce69d06f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00535.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00535") -public class BenchmarkTest00535 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00535")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00536.java b/OWASP DATASET CLEANED/BenchmarkTest00536.java deleted file mode 100644 index 05861e826d07ba2645383455d21cc3f0ffad2968..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00536.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00536") -public class BenchmarkTest00536 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00536")) { - param = name; - flag = false; - } - } - } - } - - String bar = "safe!"; - java.util.HashMap map28714 = new java.util.HashMap(); - map28714.put("keyA-28714", "a-Value"); // put some stuff in the collection - map28714.put("keyB-28714", param); // put it in a collection - map28714.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map28714.get("keyB-28714"); // get it back out - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00537.java b/OWASP DATASET CLEANED/BenchmarkTest00537.java deleted file mode 100644 index 9cc2078b0560b68af3bbf3600570f72d5634f6a5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00537.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00537") -public class BenchmarkTest00537 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00537")) { - param = name; - flag = false; - } - } - } - } - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00538.java b/OWASP DATASET CLEANED/BenchmarkTest00538.java deleted file mode 100644 index 32a0d79d5a7634876e227fa67636bbe3bbce2913..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00538.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00538") -public class BenchmarkTest00538 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00538")) { - param = name; - flag = false; - } - } - } - } - - // Chain a bunch of propagators in sequence - String a75053 = param; // assign - StringBuilder b75053 = new StringBuilder(a75053); // stick in stringbuilder - b75053.append(" SafeStuff"); // append some safe content - b75053.replace( - b75053.length() - "Chars".length(), - b75053.length(), - "Chars"); // replace some of the end content - java.util.HashMap map75053 = new java.util.HashMap(); - map75053.put("key75053", b75053.toString()); // put in a collection - String c75053 = (String) map75053.get("key75053"); // get it back out - String d75053 = c75053.substring(0, c75053.length() - 1); // extract most of it - String e75053 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d75053.getBytes()))); // B64 encode and decode it - String f75053 = e75053.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f75053); // reflection - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00539.java b/OWASP DATASET CLEANED/BenchmarkTest00539.java deleted file mode 100644 index aca7f7ccb71ea60700351af3bd53b45f060d2402..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00539.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00539") -public class BenchmarkTest00539 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00539")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00540.java b/OWASP DATASET CLEANED/BenchmarkTest00540.java deleted file mode 100644 index 9941769ac7d742c8c4c21956626613d9f70c89f6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00540.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00540") -public class BenchmarkTest00540 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00540")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00541.java b/OWASP DATASET CLEANED/BenchmarkTest00541.java deleted file mode 100644 index bb8b5dd16eb970ea9d2d4fc8c9a5751ec0f2c076..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00541.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00541") -public class BenchmarkTest00541 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00541")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00542.java b/OWASP DATASET CLEANED/BenchmarkTest00542.java deleted file mode 100644 index 62fbcf4a0c03a2dd4259730b5989b478ba733ea2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00542.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00542") -public class BenchmarkTest00542 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00542")) { - param = name; - flag = false; - } - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00543.java b/OWASP DATASET CLEANED/BenchmarkTest00543.java deleted file mode 100644 index 2fa3f24739621b165cf3ef9e3a59e45e422bafe0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00543.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-00/BenchmarkTest00543") -public class BenchmarkTest00543 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00543")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00544.java b/OWASP DATASET CLEANED/BenchmarkTest00544.java deleted file mode 100644 index 961df4d70bda92c944bd8c870735fa09dbcc0350..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00544.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00544") -public class BenchmarkTest00544 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00544")) { - param = name; - flag = false; - } - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00545.java b/OWASP DATASET CLEANED/BenchmarkTest00545.java deleted file mode 100644 index e80b61b2fa74a738f0880fe134c029f414b033e3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00545.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00545") -public class BenchmarkTest00545 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00545")) { - param = name; - flag = false; - } - } - } - } - - // Chain a bunch of propagators in sequence - String a80566 = param; // assign - StringBuilder b80566 = new StringBuilder(a80566); // stick in stringbuilder - b80566.append(" SafeStuff"); // append some safe content - b80566.replace( - b80566.length() - "Chars".length(), - b80566.length(), - "Chars"); // replace some of the end content - java.util.HashMap map80566 = new java.util.HashMap(); - map80566.put("key80566", b80566.toString()); // put in a collection - String c80566 = (String) map80566.get("key80566"); // get it back out - String d80566 = c80566.substring(0, c80566.length() - 1); // extract most of it - String e80566 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d80566.getBytes()))); // B64 encode and decode it - String f80566 = e80566.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g80566 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g80566); // reflection - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00546.java b/OWASP DATASET CLEANED/BenchmarkTest00546.java deleted file mode 100644 index 898160f8a68d15b0b94a389c2ba0af6b4d184731..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00546.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00546") -public class BenchmarkTest00546 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00546")) { - param = name; - flag = false; - } - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00547.java b/OWASP DATASET CLEANED/BenchmarkTest00547.java deleted file mode 100644 index fd1b7bd0082f546b022897539b4e611c8d384d81..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00547.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00547") -public class BenchmarkTest00547 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00547")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00548.java b/OWASP DATASET CLEANED/BenchmarkTest00548.java deleted file mode 100644 index 0aefe4de9e347e24b6586bbd97103f592935a03b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00548.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00548") -public class BenchmarkTest00548 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00548")) { - param = name; - flag = false; - } - } - } - } - - // Chain a bunch of propagators in sequence - String a52901 = param; // assign - StringBuilder b52901 = new StringBuilder(a52901); // stick in stringbuilder - b52901.append(" SafeStuff"); // append some safe content - b52901.replace( - b52901.length() - "Chars".length(), - b52901.length(), - "Chars"); // replace some of the end content - java.util.HashMap map52901 = new java.util.HashMap(); - map52901.put("key52901", b52901.toString()); // put in a collection - String c52901 = (String) map52901.get("key52901"); // get it back out - String d52901 = c52901.substring(0, c52901.length() - 1); // extract most of it - String e52901 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d52901.getBytes()))); // B64 encode and decode it - String f52901 = e52901.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g52901 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g52901); // reflection - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00549.java b/OWASP DATASET CLEANED/BenchmarkTest00549.java deleted file mode 100644 index edfc6c79053bbd12dcc4b52412398bd7069154c7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00549.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00549") -public class BenchmarkTest00549 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00549")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00550.java b/OWASP DATASET CLEANED/BenchmarkTest00550.java deleted file mode 100644 index ac568138263112aca4d75dfac7faa1d1761d08f2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00550.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00550") -public class BenchmarkTest00550 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00550")) { - param = name; - flag = false; - } - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00551.java b/OWASP DATASET CLEANED/BenchmarkTest00551.java deleted file mode 100644 index f5b7944fac01d8b1c9f03567f75b51f22ed3ad7d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00551.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00551") -public class BenchmarkTest00551 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00551")) { - param = name; - flag = false; - } - } - } - } - - String bar = param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00552.java b/OWASP DATASET CLEANED/BenchmarkTest00552.java deleted file mode 100644 index bcdf8915734523fcb108b893eae75e02ddc31c8c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00552.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00552") -public class BenchmarkTest00552 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00552")) { - param = name; - flag = false; - } - } - } - } - - String bar = "safe!"; - java.util.HashMap map63597 = new java.util.HashMap(); - map63597.put("keyA-63597", "a-Value"); // put some stuff in the collection - map63597.put("keyB-63597", param); // put it in a collection - map63597.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map63597.get("keyB-63597"); // get it back out - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00553.java b/OWASP DATASET CLEANED/BenchmarkTest00553.java deleted file mode 100644 index 6a9c6a45cc08e30695dab41c974ccffc626ec30b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00553.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00553") -public class BenchmarkTest00553 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00553")) { - param = name; - flag = false; - } - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00554.java b/OWASP DATASET CLEANED/BenchmarkTest00554.java deleted file mode 100644 index e65fe1bd9102cb0fab389fa8a87a0e5575b63dc8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00554.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00554") -public class BenchmarkTest00554 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00554")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00555.java b/OWASP DATASET CLEANED/BenchmarkTest00555.java deleted file mode 100644 index 576793e002df79c5b6710ebf98d4665e6151604f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00555.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00555") -public class BenchmarkTest00555 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00555")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00556.java b/OWASP DATASET CLEANED/BenchmarkTest00556.java deleted file mode 100644 index 16b466c3e908265665074f0b0f3b41c9a642530b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00556.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00556") -public class BenchmarkTest00556 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00556")) { - param = name; - flag = false; - } - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00557.java b/OWASP DATASET CLEANED/BenchmarkTest00557.java deleted file mode 100644 index e01e78f2e7fb32e8f5052ee3f456163514a238c0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00557.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00557") -public class BenchmarkTest00557 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00557")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00558.java b/OWASP DATASET CLEANED/BenchmarkTest00558.java deleted file mode 100644 index 3371dbbc1987b1c012c06518834ffb806aa2c1a6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00558.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00558") -public class BenchmarkTest00558 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00558")) { - param = name; - flag = false; - } - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00559.java b/OWASP DATASET CLEANED/BenchmarkTest00559.java deleted file mode 100644 index 700cf87216057bcebb551b3535bc352510332a2d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00559.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00559") -public class BenchmarkTest00559 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00559")) { - param = name; - flag = false; - } - } - } - } - - // Chain a bunch of propagators in sequence - String a39502 = param; // assign - StringBuilder b39502 = new StringBuilder(a39502); // stick in stringbuilder - b39502.append(" SafeStuff"); // append some safe content - b39502.replace( - b39502.length() - "Chars".length(), - b39502.length(), - "Chars"); // replace some of the end content - java.util.HashMap map39502 = new java.util.HashMap(); - map39502.put("key39502", b39502.toString()); // put in a collection - String c39502 = (String) map39502.get("key39502"); // get it back out - String d39502 = c39502.substring(0, c39502.length() - 1); // extract most of it - String e39502 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d39502.getBytes()))); // B64 encode and decode it - String f39502 = e39502.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g39502 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g39502); // reflection - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00560.java b/OWASP DATASET CLEANED/BenchmarkTest00560.java deleted file mode 100644 index 64e5ad02c30bebdf549ee6c72a1a17a8b3e06b16..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00560.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00560") -public class BenchmarkTest00560 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00560")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00561.java b/OWASP DATASET CLEANED/BenchmarkTest00561.java deleted file mode 100644 index 05dd11209f6b1cc4e9dc455c6e722d8277cde786..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00561.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00561") -public class BenchmarkTest00561 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00561")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00562.java b/OWASP DATASET CLEANED/BenchmarkTest00562.java deleted file mode 100644 index 8a9668a12f1f97ad209f14199efdf3ded6d60a34..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00562.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00562") -public class BenchmarkTest00562 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00562")) { - param = name; - flag = false; - } - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00563.java b/OWASP DATASET CLEANED/BenchmarkTest00563.java deleted file mode 100644 index 32f8eb0ad216a6a5bf52952acc7e1e7e6791527b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00563.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00563") -public class BenchmarkTest00563 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00563")) { - param = name; - flag = false; - } - } - } - } - - String bar = param; - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00564.java b/OWASP DATASET CLEANED/BenchmarkTest00564.java deleted file mode 100644 index 8f79179b32281c0e45acfb078025cc06ce4b3b99..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00564.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00564") -public class BenchmarkTest00564 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00564")) { - param = name; - flag = false; - } - } - } - } - - StringBuilder sbxyz41882 = new StringBuilder(param); - String bar = sbxyz41882.append("_SafeStuff").toString(); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00565.java b/OWASP DATASET CLEANED/BenchmarkTest00565.java deleted file mode 100644 index eafe34dd52d6a34fbe4e3f75c6fcf16e344c08d1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00565.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00565") -public class BenchmarkTest00565 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00565")) { - param = name; - flag = false; - } - } - } - } - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00566.java b/OWASP DATASET CLEANED/BenchmarkTest00566.java deleted file mode 100644 index a810b0257deb96c76dc49825aed7cdcff2d0f633..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00566.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00566") -public class BenchmarkTest00566 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00566")) { - param = name; - flag = false; - } - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00567.java b/OWASP DATASET CLEANED/BenchmarkTest00567.java deleted file mode 100644 index 1ced43750aee6509a68e887c43f7f718e86aa46b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00567.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00567") -public class BenchmarkTest00567 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00567")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00568.java b/OWASP DATASET CLEANED/BenchmarkTest00568.java deleted file mode 100644 index 394eb613ea2f5063e6b68517d716ddb4cfd821d2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00568.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00568") -public class BenchmarkTest00568 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00568")) { - param = name; - flag = false; - } - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00569.java b/OWASP DATASET CLEANED/BenchmarkTest00569.java deleted file mode 100644 index 060233e691d7d7d7cbb3774a800ba04e4fdcb7c1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00569.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00569") -public class BenchmarkTest00569 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00569")) { - param = name; - flag = false; - } - } - } - } - - // Chain a bunch of propagators in sequence - String a6821 = param; // assign - StringBuilder b6821 = new StringBuilder(a6821); // stick in stringbuilder - b6821.append(" SafeStuff"); // append some safe content - b6821.replace( - b6821.length() - "Chars".length(), - b6821.length(), - "Chars"); // replace some of the end content - java.util.HashMap map6821 = new java.util.HashMap(); - map6821.put("key6821", b6821.toString()); // put in a collection - String c6821 = (String) map6821.get("key6821"); // get it back out - String d6821 = c6821.substring(0, c6821.length() - 1); // extract most of it - String e6821 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d6821.getBytes()))); // B64 encode and decode it - String f6821 = e6821.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g6821 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g6821); // reflection - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00570.java b/OWASP DATASET CLEANED/BenchmarkTest00570.java deleted file mode 100644 index 09006b5445513f35b1ba383eba9af24f6baaf366..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00570.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00570") -public class BenchmarkTest00570 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00570")) { - param = name; - flag = false; - } - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00571.java b/OWASP DATASET CLEANED/BenchmarkTest00571.java deleted file mode 100644 index 34b39a81c73f55f9972dd0dedb1f15e95a1d47d3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00571.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00571") -public class BenchmarkTest00571 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00571")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00572.java b/OWASP DATASET CLEANED/BenchmarkTest00572.java deleted file mode 100644 index 791673d4d28c344eb3ac8c075731db9ef06e9ec5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00572.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00572") -public class BenchmarkTest00572 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00572")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00573.java b/OWASP DATASET CLEANED/BenchmarkTest00573.java deleted file mode 100644 index cc82f2820b47111ee98308f09c0b1b44dfd90cf5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00573.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00573") -public class BenchmarkTest00573 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00573")) { - param = name; - flag = false; - } - } - } - } - - String bar = param; - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00574.java b/OWASP DATASET CLEANED/BenchmarkTest00574.java deleted file mode 100644 index 92d29aba9de577aa5a642ea0d575d11947e85853..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00574.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00574") -public class BenchmarkTest00574 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00574")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00575.java b/OWASP DATASET CLEANED/BenchmarkTest00575.java deleted file mode 100644 index 6a8ec277fc8c2c00bfa1af30fb96f81d5795e7a4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00575.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00575") -public class BenchmarkTest00575 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00575")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00576.java b/OWASP DATASET CLEANED/BenchmarkTest00576.java deleted file mode 100644 index 1444ae7414d6fdcc9661c65a9fe3761d44a04f6e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00576.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00576") -public class BenchmarkTest00576 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00576")) { - param = name; - flag = false; - } - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00577.java b/OWASP DATASET CLEANED/BenchmarkTest00577.java deleted file mode 100644 index 025c622609d0f65f0936c6c24ce9c8b72c1e63c9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00577.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00577") -public class BenchmarkTest00577 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00577")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00578.java b/OWASP DATASET CLEANED/BenchmarkTest00578.java deleted file mode 100644 index 13f136b7fa1c13e1f651c48da716ab90f1a976ac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00578.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00578") -public class BenchmarkTest00578 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00578")) { - param = name; - flag = false; - } - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00579.java b/OWASP DATASET CLEANED/BenchmarkTest00579.java deleted file mode 100644 index 4f006bf46344b111d72ba7935a87b0b36200e490..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00579.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00579") -public class BenchmarkTest00579 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00579")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00580.java b/OWASP DATASET CLEANED/BenchmarkTest00580.java deleted file mode 100644 index b4cf18f54d4d6ca769767dd109e3eba62b3793cb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00580.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00580") -public class BenchmarkTest00580 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00580")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00581.java b/OWASP DATASET CLEANED/BenchmarkTest00581.java deleted file mode 100644 index aa36be413440e4c8fd3057eb9f575e1ebd316c85..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00581.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00581") -public class BenchmarkTest00581 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00581")) { - param = name; - flag = false; - } - } - } - } - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00582.java b/OWASP DATASET CLEANED/BenchmarkTest00582.java deleted file mode 100644 index 5dc0548f2eb32d700540cbfcb9d2e188440424b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00582.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00582") -public class BenchmarkTest00582 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00582")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00583.java b/OWASP DATASET CLEANED/BenchmarkTest00583.java deleted file mode 100644 index 37c8b5733a46217cb9b93d2bb24e5205b55d0a52..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00583.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00583") -public class BenchmarkTest00583 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00583")) { - param = name; - flag = false; - } - } - } - } - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00584.java b/OWASP DATASET CLEANED/BenchmarkTest00584.java deleted file mode 100644 index 5bf448e1602d14d77931249b19b18457c9a806d2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00584.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00584") -public class BenchmarkTest00584 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00584")) { - param = name; - flag = false; - } - } - } - } - - String bar = "safe!"; - java.util.HashMap map23020 = new java.util.HashMap(); - map23020.put("keyA-23020", "a_Value"); // put some stuff in the collection - map23020.put("keyB-23020", param); // put it in a collection - map23020.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map23020.get("keyB-23020"); // get it back out - bar = (String) map23020.get("keyA-23020"); // get safe value back out - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00585.java b/OWASP DATASET CLEANED/BenchmarkTest00585.java deleted file mode 100644 index 9217ff2497b07bfe59df73c6b811eca7db6f5a4d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00585.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00585") -public class BenchmarkTest00585 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00585")) { - param = name; - flag = false; - } - } - } - } - - StringBuilder sbxyz49441 = new StringBuilder(param); - String bar = sbxyz49441.append("_SafeStuff").toString(); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00586.java b/OWASP DATASET CLEANED/BenchmarkTest00586.java deleted file mode 100644 index 09e2312affb13dc1bef5897b9348040f45b3db0b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00586.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00586") -public class BenchmarkTest00586 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00586")) { - param = name; - flag = false; - } - } - } - } - - String bar = "safe!"; - java.util.HashMap map58886 = new java.util.HashMap(); - map58886.put("keyA-58886", "a_Value"); // put some stuff in the collection - map58886.put("keyB-58886", param); // put it in a collection - map58886.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map58886.get("keyB-58886"); // get it back out - bar = (String) map58886.get("keyA-58886"); // get safe value back out - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00587.java b/OWASP DATASET CLEANED/BenchmarkTest00587.java deleted file mode 100644 index 128abb8b53bacb5e69b4e1e720851e4514b433ec..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00587.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00587") -public class BenchmarkTest00587 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00587")) { - param = name; - flag = false; - } - } - } - } - - String bar = "safe!"; - java.util.HashMap map44465 = new java.util.HashMap(); - map44465.put("keyA-44465", "a-Value"); // put some stuff in the collection - map44465.put("keyB-44465", param); // put it in a collection - map44465.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map44465.get("keyB-44465"); // get it back out - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00588.java b/OWASP DATASET CLEANED/BenchmarkTest00588.java deleted file mode 100644 index 2e6470a3ce4bdceab847618c6cbc5b991c75f3f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00588.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00588") -public class BenchmarkTest00588 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00588")) { - param = name; - flag = false; - } - } - } - } - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00589.java b/OWASP DATASET CLEANED/BenchmarkTest00589.java deleted file mode 100644 index 9952780baadb096950055ab1a0e584a168544297..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00589.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00589") -public class BenchmarkTest00589 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00589")) { - param = name; - flag = false; - } - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00590.java b/OWASP DATASET CLEANED/BenchmarkTest00590.java deleted file mode 100644 index cba00d5b4d46405370bf1fdcca6bc39f04e232ad..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00590.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00590") -public class BenchmarkTest00590 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00590")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00591.java b/OWASP DATASET CLEANED/BenchmarkTest00591.java deleted file mode 100644 index b9e3d544a6ac61ffbf74cca8be17d6e5f843bc0a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00591.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00591") -public class BenchmarkTest00591 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00591")) { - param = name; - flag = false; - } - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00592.java b/OWASP DATASET CLEANED/BenchmarkTest00592.java deleted file mode 100644 index 15b267edc6dfe20166dff2946b63a18a7bc993f1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00592.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00592") -public class BenchmarkTest00592 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00592")) { - param = name; - flag = false; - } - } - } - } - - // Chain a bunch of propagators in sequence - String a36502 = param; // assign - StringBuilder b36502 = new StringBuilder(a36502); // stick in stringbuilder - b36502.append(" SafeStuff"); // append some safe content - b36502.replace( - b36502.length() - "Chars".length(), - b36502.length(), - "Chars"); // replace some of the end content - java.util.HashMap map36502 = new java.util.HashMap(); - map36502.put("key36502", b36502.toString()); // put in a collection - String c36502 = (String) map36502.get("key36502"); // get it back out - String d36502 = c36502.substring(0, c36502.length() - 1); // extract most of it - String e36502 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d36502.getBytes()))); // B64 encode and decode it - String f36502 = e36502.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g36502 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g36502); // reflection - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00593.java b/OWASP DATASET CLEANED/BenchmarkTest00593.java deleted file mode 100644 index d0b3de8ed22dfdc59d1ed3df7a70047ae2a9deb5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00593.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00593") -public class BenchmarkTest00593 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00593")) { - param = name; - flag = false; - } - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00594.java b/OWASP DATASET CLEANED/BenchmarkTest00594.java deleted file mode 100644 index a6f8dda124cdb7d465a1c3f3948babd0e6309bf3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00594.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00594") -public class BenchmarkTest00594 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00594")) { - param = name; - flag = false; - } - } - } - } - - String bar = "safe!"; - java.util.HashMap map29056 = new java.util.HashMap(); - map29056.put("keyA-29056", "a-Value"); // put some stuff in the collection - map29056.put("keyB-29056", param); // put it in a collection - map29056.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map29056.get("keyB-29056"); // get it back out - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00595.java b/OWASP DATASET CLEANED/BenchmarkTest00595.java deleted file mode 100644 index b21eaad7e2b01061f30fec55ec80643f63aab70a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00595.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00595") -public class BenchmarkTest00595 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00595")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00596.java b/OWASP DATASET CLEANED/BenchmarkTest00596.java deleted file mode 100644 index 510dd017d805ec79f379048eefafad496f49fc30..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00596.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00596") -public class BenchmarkTest00596 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00596")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00597.java b/OWASP DATASET CLEANED/BenchmarkTest00597.java deleted file mode 100644 index aa5589e0c33f068abf833735b35805ea13decc8a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00597.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00597") -public class BenchmarkTest00597 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00597")) { - param = name; - flag = false; - } - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00598.java b/OWASP DATASET CLEANED/BenchmarkTest00598.java deleted file mode 100644 index 0141f393fd4a95d45269859276c49a73e2bd968d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00598.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00598") -public class BenchmarkTest00598 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00598")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00599.java b/OWASP DATASET CLEANED/BenchmarkTest00599.java deleted file mode 100644 index 5c2b1865e985c7be1ef332872c6927318cdb5c76..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00599.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00599") -public class BenchmarkTest00599 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00599")) { - param = name; - flag = false; - } - } - } - } - - // Chain a bunch of propagators in sequence - String a99467 = param; // assign - StringBuilder b99467 = new StringBuilder(a99467); // stick in stringbuilder - b99467.append(" SafeStuff"); // append some safe content - b99467.replace( - b99467.length() - "Chars".length(), - b99467.length(), - "Chars"); // replace some of the end content - java.util.HashMap map99467 = new java.util.HashMap(); - map99467.put("key99467", b99467.toString()); // put in a collection - String c99467 = (String) map99467.get("key99467"); // get it back out - String d99467 = c99467.substring(0, c99467.length() - 1); // extract most of it - String e99467 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d99467.getBytes()))); // B64 encode and decode it - String f99467 = e99467.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g99467 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g99467); // reflection - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00600.java b/OWASP DATASET CLEANED/BenchmarkTest00600.java deleted file mode 100644 index d9af4eeb8e8b4f36b042fed46f8cd998a3d513f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00600.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00600") -public class BenchmarkTest00600 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00600")) { - param = name; - flag = false; - } - } - } - } - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00601.java b/OWASP DATASET CLEANED/BenchmarkTest00601.java deleted file mode 100644 index 63b72dc4b572f6332d627526f21901fb94f6cd6d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00601.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00601") -public class BenchmarkTest00601 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00601")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00602.java b/OWASP DATASET CLEANED/BenchmarkTest00602.java deleted file mode 100644 index 1442ed6d366fd3e3fc49ae8a81f353ee67376c4d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00602.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00602") -public class BenchmarkTest00602 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00602")) { - param = name; - flag = false; - } - } - } - } - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00603.java b/OWASP DATASET CLEANED/BenchmarkTest00603.java deleted file mode 100644 index ab629015206eafd1497ed325317e81e81f24e4cd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00603.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00603") -public class BenchmarkTest00603 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00603")) { - param = name; - flag = false; - } - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00604.java b/OWASP DATASET CLEANED/BenchmarkTest00604.java deleted file mode 100644 index 362b07436c8e5c6c67761bd34a21ee8fd4f308fe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00604.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00604") -public class BenchmarkTest00604 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00604")) { - param = name; - flag = false; - } - } - } - } - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00605.java b/OWASP DATASET CLEANED/BenchmarkTest00605.java deleted file mode 100644 index 8cedb8b166d5bd733f5753001d9dc292cd81b70a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00605.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00605") -public class BenchmarkTest00605 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00605")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00606.java b/OWASP DATASET CLEANED/BenchmarkTest00606.java deleted file mode 100644 index 0a8aba5f62965e6bad303560571e6b0d779e6ef7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00606.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00606") -public class BenchmarkTest00606 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00606")) { - param = name; - flag = false; - } - } - } - } - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00607.java b/OWASP DATASET CLEANED/BenchmarkTest00607.java deleted file mode 100644 index cdecc16dd1490b8170312907f7401a124723f27c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00607.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest00607") -public class BenchmarkTest00607 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest00607")) { - param = name; - flag = false; - } - } - } - } - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00608.java b/OWASP DATASET CLEANED/BenchmarkTest00608.java deleted file mode 100644 index d6f39c7443ecd79526e0293cb73d50a0cbaacdb3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00608.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00608") -public class BenchmarkTest00608 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00608"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00609.java b/OWASP DATASET CLEANED/BenchmarkTest00609.java deleted file mode 100644 index 315f401d3785feea8ef2dae65b6cc5ddf137600d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00609.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00609") -public class BenchmarkTest00609 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00609"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00610.java b/OWASP DATASET CLEANED/BenchmarkTest00610.java deleted file mode 100644 index 2d0e15dbddb3fdaf992be26f87b9db2b2067da94..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00610.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00610") -public class BenchmarkTest00610 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00610"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a51289 = param; // assign - StringBuilder b51289 = new StringBuilder(a51289); // stick in stringbuilder - b51289.append(" SafeStuff"); // append some safe content - b51289.replace( - b51289.length() - "Chars".length(), - b51289.length(), - "Chars"); // replace some of the end content - java.util.HashMap map51289 = new java.util.HashMap(); - map51289.put("key51289", b51289.toString()); // put in a collection - String c51289 = (String) map51289.get("key51289"); // get it back out - String d51289 = c51289.substring(0, c51289.length() - 1); // extract most of it - String e51289 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d51289.getBytes()))); // B64 encode and decode it - String f51289 = e51289.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g51289 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g51289); // reflection - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00611.java b/OWASP DATASET CLEANED/BenchmarkTest00611.java deleted file mode 100644 index bad784c9c2f047350bbd52530c91f46e5f3b5b8e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00611.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00611") -public class BenchmarkTest00611 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00611"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00612.java b/OWASP DATASET CLEANED/BenchmarkTest00612.java deleted file mode 100644 index 4649ecb72fc3f3c45d87b4b06df4cd512f6a7dbf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00612.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00612") -public class BenchmarkTest00612 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00612"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00613.java b/OWASP DATASET CLEANED/BenchmarkTest00613.java deleted file mode 100644 index df406bb74d1230aa856f099999dafd33c57bdeec..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00613.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00613") -public class BenchmarkTest00613 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00613"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map67704 = new java.util.HashMap(); - map67704.put("keyA-67704", "a_Value"); // put some stuff in the collection - map67704.put("keyB-67704", param); // put it in a collection - map67704.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map67704.get("keyB-67704"); // get it back out - bar = (String) map67704.get("keyA-67704"); // get safe value back out - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00614.java b/OWASP DATASET CLEANED/BenchmarkTest00614.java deleted file mode 100644 index 6a90f194e15be27a593b235a81c85ad324a06cc8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00614.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00614") -public class BenchmarkTest00614 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00614"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00615.java b/OWASP DATASET CLEANED/BenchmarkTest00615.java deleted file mode 100644 index e342d6f22759e444f299ad16bfadce5e1940498b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00615.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00615") -public class BenchmarkTest00615 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00615"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map4123 = new java.util.HashMap(); - map4123.put("keyA-4123", "a_Value"); // put some stuff in the collection - map4123.put("keyB-4123", param); // put it in a collection - map4123.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map4123.get("keyB-4123"); // get it back out - bar = (String) map4123.get("keyA-4123"); // get safe value back out - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00616.java b/OWASP DATASET CLEANED/BenchmarkTest00616.java deleted file mode 100644 index 22b5fd3f273f0f373ea6fa92c3a85bb46387f060..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00616.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00616") -public class BenchmarkTest00616 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00616"); - if (param == null) param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00617.java b/OWASP DATASET CLEANED/BenchmarkTest00617.java deleted file mode 100644 index ae39550688624020756ae1aa7be17ead17f8938b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00617.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00617") -public class BenchmarkTest00617 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00617"); - if (param == null) param = ""; - - StringBuilder sbxyz57328 = new StringBuilder(param); - String bar = sbxyz57328.append("_SafeStuff").toString(); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00618.java b/OWASP DATASET CLEANED/BenchmarkTest00618.java deleted file mode 100644 index bb09fe37a845cf18ff191a4e5cc18f76b0c40d4c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00618.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00618") -public class BenchmarkTest00618 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00618"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00619.java b/OWASP DATASET CLEANED/BenchmarkTest00619.java deleted file mode 100644 index 764a7886958929e8f32d2782737f2ed89a6f3d20..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00619.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00619") -public class BenchmarkTest00619 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00619"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00620.java b/OWASP DATASET CLEANED/BenchmarkTest00620.java deleted file mode 100644 index 2c997486e87a714f02bba065592cbef5f594216e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00620.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00620") -public class BenchmarkTest00620 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00620"); - if (param == null) param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00621.java b/OWASP DATASET CLEANED/BenchmarkTest00621.java deleted file mode 100644 index 8bcbb255517c5bbb7cdfd87c0f49ae6735dd3d7b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00621.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00621") -public class BenchmarkTest00621 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00621"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a28566 = param; // assign - StringBuilder b28566 = new StringBuilder(a28566); // stick in stringbuilder - b28566.append(" SafeStuff"); // append some safe content - b28566.replace( - b28566.length() - "Chars".length(), - b28566.length(), - "Chars"); // replace some of the end content - java.util.HashMap map28566 = new java.util.HashMap(); - map28566.put("key28566", b28566.toString()); // put in a collection - String c28566 = (String) map28566.get("key28566"); // get it back out - String d28566 = c28566.substring(0, c28566.length() - 1); // extract most of it - String e28566 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d28566.getBytes()))); // B64 encode and decode it - String f28566 = e28566.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g28566 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g28566); // reflection - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00622.java b/OWASP DATASET CLEANED/BenchmarkTest00622.java deleted file mode 100644 index f28bfafa2eece20ca67b62db733affd0357240ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00622.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00622") -public class BenchmarkTest00622 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00622"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00623.java b/OWASP DATASET CLEANED/BenchmarkTest00623.java deleted file mode 100644 index 6bebd29873fcbb1ccfa863fbbcc207136d128daf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00623.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00623") -public class BenchmarkTest00623 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00623"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00624.java b/OWASP DATASET CLEANED/BenchmarkTest00624.java deleted file mode 100644 index 3ec7f14c6635c38c7bc44fd4463f004c70fd2d18..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00624.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00624") -public class BenchmarkTest00624 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00624"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00625.java b/OWASP DATASET CLEANED/BenchmarkTest00625.java deleted file mode 100644 index c754300307bb109d1323ce9f9cbfba0dca710eb4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00625.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00625") -public class BenchmarkTest00625 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00625"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00626.java b/OWASP DATASET CLEANED/BenchmarkTest00626.java deleted file mode 100644 index 0196e59a876f9cb3a3de7eb903a11bd5727a8f17..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00626.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00626") -public class BenchmarkTest00626 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00626"); - if (param == null) param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00627.java b/OWASP DATASET CLEANED/BenchmarkTest00627.java deleted file mode 100644 index 4496fa890f56eddfe0f988b0733d75812f8958a9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00627.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00627") -public class BenchmarkTest00627 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00627"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00628.java b/OWASP DATASET CLEANED/BenchmarkTest00628.java deleted file mode 100644 index 9c2d50bc61fdb9416a394fe56d7fad0a6ad52f11..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00628.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00628") -public class BenchmarkTest00628 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00628"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a24315 = param; // assign - StringBuilder b24315 = new StringBuilder(a24315); // stick in stringbuilder - b24315.append(" SafeStuff"); // append some safe content - b24315.replace( - b24315.length() - "Chars".length(), - b24315.length(), - "Chars"); // replace some of the end content - java.util.HashMap map24315 = new java.util.HashMap(); - map24315.put("key24315", b24315.toString()); // put in a collection - String c24315 = (String) map24315.get("key24315"); // get it back out - String d24315 = c24315.substring(0, c24315.length() - 1); // extract most of it - String e24315 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d24315.getBytes()))); // B64 encode and decode it - String f24315 = e24315.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g24315 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g24315); // reflection - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00629.java b/OWASP DATASET CLEANED/BenchmarkTest00629.java deleted file mode 100644 index cc57008dc0d83469a5e095644226d0e5ce442862..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00629.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00629") -public class BenchmarkTest00629 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00629"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00630.java b/OWASP DATASET CLEANED/BenchmarkTest00630.java deleted file mode 100644 index 8ab20cfcad68745c6bab52e270a10dcae66c406e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00630.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00630") -public class BenchmarkTest00630 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00630"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00631.java b/OWASP DATASET CLEANED/BenchmarkTest00631.java deleted file mode 100644 index 1ba1618f4bbe4b2fda911962dd8ccd41be6907a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00631.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00631") -public class BenchmarkTest00631 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00631"); - if (param == null) param = ""; - - StringBuilder sbxyz28895 = new StringBuilder(param); - String bar = sbxyz28895.append("_SafeStuff").toString(); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00632.java b/OWASP DATASET CLEANED/BenchmarkTest00632.java deleted file mode 100644 index 4228def0869c715198612727f6c33879ab75dbf0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00632.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00632") -public class BenchmarkTest00632 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00632"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00633.java b/OWASP DATASET CLEANED/BenchmarkTest00633.java deleted file mode 100644 index a50ff65755afe696464a5d4cb749f276ceb41bf2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00633.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00633") -public class BenchmarkTest00633 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00633"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00634.java b/OWASP DATASET CLEANED/BenchmarkTest00634.java deleted file mode 100644 index e978d5695fc6735e877acbcdcee573c3822e0a96..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00634.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00634") -public class BenchmarkTest00634 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00634"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00635.java b/OWASP DATASET CLEANED/BenchmarkTest00635.java deleted file mode 100644 index ce0809d06c9e6bfaa19abeec80fbd21709dd43cc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00635.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00635") -public class BenchmarkTest00635 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00635"); - if (param == null) param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00636.java b/OWASP DATASET CLEANED/BenchmarkTest00636.java deleted file mode 100644 index cc5f8723c190cfc23651e623c72008a4eb27e1f7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00636.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00636") -public class BenchmarkTest00636 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00636"); - if (param == null) param = ""; - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00637.java b/OWASP DATASET CLEANED/BenchmarkTest00637.java deleted file mode 100644 index 24c033dc88c7b9db38a40107ffd4be03b88d5034..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00637.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00637") -public class BenchmarkTest00637 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00637"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00638.java b/OWASP DATASET CLEANED/BenchmarkTest00638.java deleted file mode 100644 index c9132849ae1eb6da72570f50f4b65b742c73d69e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00638.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00638") -public class BenchmarkTest00638 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00638"); - if (param == null) param = ""; - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00639.java b/OWASP DATASET CLEANED/BenchmarkTest00639.java deleted file mode 100644 index 600ac89f93703001991ffc56606d145949196254..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00639.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00639") -public class BenchmarkTest00639 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00639"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00640.java b/OWASP DATASET CLEANED/BenchmarkTest00640.java deleted file mode 100644 index 8717ee8d5d4f598032fe0fac2162c761d6076a98..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00640.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00640") -public class BenchmarkTest00640 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00640"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00641.java b/OWASP DATASET CLEANED/BenchmarkTest00641.java deleted file mode 100644 index e3243a7fbff005ba5c67c4e46578270a1374431c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00641.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00641") -public class BenchmarkTest00641 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00641"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00642.java b/OWASP DATASET CLEANED/BenchmarkTest00642.java deleted file mode 100644 index 044e0c034e9d2babd4a04141073697566eaf30c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00642.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00642") -public class BenchmarkTest00642 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00642"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00643.java b/OWASP DATASET CLEANED/BenchmarkTest00643.java deleted file mode 100644 index 82665439fec7e11ac2af5fc85e0ff0b0370861d9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00643.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00643") -public class BenchmarkTest00643 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00643"); - if (param == null) param = ""; - - StringBuilder sbxyz31207 = new StringBuilder(param); - String bar = sbxyz31207.append("_SafeStuff").toString(); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00644.java b/OWASP DATASET CLEANED/BenchmarkTest00644.java deleted file mode 100644 index 8553c3b8fec051c6283f65def8da4b7c2b0813b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00644.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00644") -public class BenchmarkTest00644 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00644"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00645.java b/OWASP DATASET CLEANED/BenchmarkTest00645.java deleted file mode 100644 index 8019ca2c4ccbe53c8815e52f020281df3472f2ba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00645.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00645") -public class BenchmarkTest00645 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00645"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00646.java b/OWASP DATASET CLEANED/BenchmarkTest00646.java deleted file mode 100644 index ab43da700797370d7c41a402cb5e0af3d11c45cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00646.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00646") -public class BenchmarkTest00646 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00646"); - if (param == null) param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00647.java b/OWASP DATASET CLEANED/BenchmarkTest00647.java deleted file mode 100644 index a1f46edb16988fb72abdb7613d580eb504e5cce9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00647.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00647") -public class BenchmarkTest00647 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00647"); - if (param == null) param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00648.java b/OWASP DATASET CLEANED/BenchmarkTest00648.java deleted file mode 100644 index 442633f1d7f117e91eac9be6bb8770ca5ada2fba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00648.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00648") -public class BenchmarkTest00648 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00648"); - if (param == null) param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00649.java b/OWASP DATASET CLEANED/BenchmarkTest00649.java deleted file mode 100644 index 0c54d9387af70c57f5e3621d466471e287e37544..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00649.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00649") -public class BenchmarkTest00649 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00649"); - if (param == null) param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00650.java b/OWASP DATASET CLEANED/BenchmarkTest00650.java deleted file mode 100644 index 98513050f33a535d0453cff7139952011bb170ab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00650.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00650") -public class BenchmarkTest00650 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00650"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a17321 = param; // assign - StringBuilder b17321 = new StringBuilder(a17321); // stick in stringbuilder - b17321.append(" SafeStuff"); // append some safe content - b17321.replace( - b17321.length() - "Chars".length(), - b17321.length(), - "Chars"); // replace some of the end content - java.util.HashMap map17321 = new java.util.HashMap(); - map17321.put("key17321", b17321.toString()); // put in a collection - String c17321 = (String) map17321.get("key17321"); // get it back out - String d17321 = c17321.substring(0, c17321.length() - 1); // extract most of it - String e17321 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d17321.getBytes()))); // B64 encode and decode it - String f17321 = e17321.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g17321 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g17321); // reflection - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00651.java b/OWASP DATASET CLEANED/BenchmarkTest00651.java deleted file mode 100644 index 135ae6bc7656d6b27331193df0cefcf9b8a93863..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00651.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00651") -public class BenchmarkTest00651 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00651"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00652.java b/OWASP DATASET CLEANED/BenchmarkTest00652.java deleted file mode 100644 index 97efcb8d5fc0b1210782d895e4f22e4f01611a2f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00652.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00652") -public class BenchmarkTest00652 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00652"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00653.java b/OWASP DATASET CLEANED/BenchmarkTest00653.java deleted file mode 100644 index 8ffa41afc118790b49e279a48b811a74ac152cd2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00653.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00653") -public class BenchmarkTest00653 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00653"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00654.java b/OWASP DATASET CLEANED/BenchmarkTest00654.java deleted file mode 100644 index 928ef5c5d6b924a74003e7d807a8d79531d9443f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00654.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00654") -public class BenchmarkTest00654 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00654"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00655.java b/OWASP DATASET CLEANED/BenchmarkTest00655.java deleted file mode 100644 index 2efbbcd2b34f13bbbb1b1cc4d3737f1c743a0fd3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00655.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00655") -public class BenchmarkTest00655 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00655"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00656.java b/OWASP DATASET CLEANED/BenchmarkTest00656.java deleted file mode 100644 index 74218f25284571f86c58f0ae3c26f1632d96a873..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00656.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00656") -public class BenchmarkTest00656 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00656"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00657.java b/OWASP DATASET CLEANED/BenchmarkTest00657.java deleted file mode 100644 index 8c22ea1f9bf92dd715ad14681d21d7053810367c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00657.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00657") -public class BenchmarkTest00657 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00657"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map27260 = new java.util.HashMap(); - map27260.put("keyA-27260", "a_Value"); // put some stuff in the collection - map27260.put("keyB-27260", param); // put it in a collection - map27260.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map27260.get("keyB-27260"); // get it back out - bar = (String) map27260.get("keyA-27260"); // get safe value back out - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00658.java b/OWASP DATASET CLEANED/BenchmarkTest00658.java deleted file mode 100644 index 7e6014dc761fb8cc60edbda773df802e2abc06dd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00658.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00658") -public class BenchmarkTest00658 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00658"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00659.java b/OWASP DATASET CLEANED/BenchmarkTest00659.java deleted file mode 100644 index 725a78f381fc23523dee7a0dbbb2ee3aea07b5a7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00659.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00659") -public class BenchmarkTest00659 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00659"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00660.java b/OWASP DATASET CLEANED/BenchmarkTest00660.java deleted file mode 100644 index 056fa469258ef98127729a65aa96a093c9cc83c6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00660.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00660") -public class BenchmarkTest00660 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00660"); - if (param == null) param = ""; - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00661.java b/OWASP DATASET CLEANED/BenchmarkTest00661.java deleted file mode 100644 index 39175cc63b51d852bb76d9fa5b268deeb059c63f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00661.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00661") -public class BenchmarkTest00661 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00661"); - if (param == null) param = ""; - - String bar = param; - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00662.java b/OWASP DATASET CLEANED/BenchmarkTest00662.java deleted file mode 100644 index 428bf00966c7cae1d220c04705e79028d14f2dae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00662.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00662") -public class BenchmarkTest00662 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00662"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00663.java b/OWASP DATASET CLEANED/BenchmarkTest00663.java deleted file mode 100644 index 32fb295f5a0455f2d51f04e9afdfb1d0f04cb0b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00663.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00663") -public class BenchmarkTest00663 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00663"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map67527 = new java.util.HashMap(); - map67527.put("keyA-67527", "a-Value"); // put some stuff in the collection - map67527.put("keyB-67527", param); // put it in a collection - map67527.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map67527.get("keyB-67527"); // get it back out - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00664.java b/OWASP DATASET CLEANED/BenchmarkTest00664.java deleted file mode 100644 index e463ee69fc42fee45c8fe7742806ede64ef6b4df..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00664.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00664") -public class BenchmarkTest00664 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00664"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a87833 = param; // assign - StringBuilder b87833 = new StringBuilder(a87833); // stick in stringbuilder - b87833.append(" SafeStuff"); // append some safe content - b87833.replace( - b87833.length() - "Chars".length(), - b87833.length(), - "Chars"); // replace some of the end content - java.util.HashMap map87833 = new java.util.HashMap(); - map87833.put("key87833", b87833.toString()); // put in a collection - String c87833 = (String) map87833.get("key87833"); // get it back out - String d87833 = c87833.substring(0, c87833.length() - 1); // extract most of it - String e87833 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d87833.getBytes()))); // B64 encode and decode it - String f87833 = e87833.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g87833 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g87833); // reflection - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00665.java b/OWASP DATASET CLEANED/BenchmarkTest00665.java deleted file mode 100644 index 49e1601ab63bbece8ba2897a54c24121845ebd1d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00665.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00665") -public class BenchmarkTest00665 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00665"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00666.java b/OWASP DATASET CLEANED/BenchmarkTest00666.java deleted file mode 100644 index 475f28e55e2a6ec28e4256ab218b3bb2051a9363..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00666.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00666") -public class BenchmarkTest00666 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00666"); - if (param == null) param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz65591 = new StringBuilder(param); - bar = sbxyz65591.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00667.java b/OWASP DATASET CLEANED/BenchmarkTest00667.java deleted file mode 100644 index 453034dd68830f99a063f1e81970a966d38c676f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00667.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00667") -public class BenchmarkTest00667 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00667"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00668.java b/OWASP DATASET CLEANED/BenchmarkTest00668.java deleted file mode 100644 index 65ab63fa8500da6a83060ccc25a167de0475b3c1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00668.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00668") -public class BenchmarkTest00668 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00668"); - if (param == null) param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00669.java b/OWASP DATASET CLEANED/BenchmarkTest00669.java deleted file mode 100644 index c4d730261370617756084346937afc8f18388ee7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00669.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00669") -public class BenchmarkTest00669 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00669"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00670.java b/OWASP DATASET CLEANED/BenchmarkTest00670.java deleted file mode 100644 index e28439864fefa0927a28cb08e9115d963ff976b8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00670.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00670") -public class BenchmarkTest00670 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00670"); - if (param == null) param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz42704 = new StringBuilder(param); - bar = sbxyz42704.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00671.java b/OWASP DATASET CLEANED/BenchmarkTest00671.java deleted file mode 100644 index 5349125e3191b4af00f15b2d781b55a95f00a819..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00671.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00671") -public class BenchmarkTest00671 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00671"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00672.java b/OWASP DATASET CLEANED/BenchmarkTest00672.java deleted file mode 100644 index efb70eb5e064fd7ccb853d4734814cda56954c96..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00672.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00672") -public class BenchmarkTest00672 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00672"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00673.java b/OWASP DATASET CLEANED/BenchmarkTest00673.java deleted file mode 100644 index 2e79baf50e7bdb1ee07c9d6d140ab0d99491b0d3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00673.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00673") -public class BenchmarkTest00673 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00673"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00674.java b/OWASP DATASET CLEANED/BenchmarkTest00674.java deleted file mode 100644 index 3bcbdac1354adb3724f3a54fee7324e294eef5f6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00674.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00674") -public class BenchmarkTest00674 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00674"); - if (param == null) param = ""; - - // Chain a bunch of propagators in sequence - String a55926 = param; // assign - StringBuilder b55926 = new StringBuilder(a55926); // stick in stringbuilder - b55926.append(" SafeStuff"); // append some safe content - b55926.replace( - b55926.length() - "Chars".length(), - b55926.length(), - "Chars"); // replace some of the end content - java.util.HashMap map55926 = new java.util.HashMap(); - map55926.put("key55926", b55926.toString()); // put in a collection - String c55926 = (String) map55926.get("key55926"); // get it back out - String d55926 = c55926.substring(0, c55926.length() - 1); // extract most of it - String e55926 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d55926.getBytes()))); // B64 encode and decode it - String f55926 = e55926.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g55926 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g55926); // reflection - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00675.java b/OWASP DATASET CLEANED/BenchmarkTest00675.java deleted file mode 100644 index 54d39e3b384c626a1d0610aa9b6e38857a4eef24..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00675.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00675") -public class BenchmarkTest00675 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00675"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new int[] {1, 2}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00676.java b/OWASP DATASET CLEANED/BenchmarkTest00676.java deleted file mode 100644 index 251f9353b1b4bb504940af4de6eb92547e8de23a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00676.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00676") -public class BenchmarkTest00676 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00676"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00677.java b/OWASP DATASET CLEANED/BenchmarkTest00677.java deleted file mode 100644 index 8517588a660c2cae7cfc5fe245dd5172acaf415f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00677.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00677") -public class BenchmarkTest00677 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00677"); - if (param == null) param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00678.java b/OWASP DATASET CLEANED/BenchmarkTest00678.java deleted file mode 100644 index ef96153d62691bb1a067051ad0ee7e4e95174f24..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00678.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00678") -public class BenchmarkTest00678 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00678"); - if (param == null) param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00679.java b/OWASP DATASET CLEANED/BenchmarkTest00679.java deleted file mode 100644 index 017e8358f553373abcc556003f56962d748daacc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00679.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00679") -public class BenchmarkTest00679 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00679"); - if (param == null) param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00680.java b/OWASP DATASET CLEANED/BenchmarkTest00680.java deleted file mode 100644 index 3d6c32aab5d3272acbc4049ba755cfa0b285ae55..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00680.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00680") -public class BenchmarkTest00680 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00680"); - if (param == null) param = ""; - - String bar = "safe!"; - java.util.HashMap map33558 = new java.util.HashMap(); - map33558.put("keyA-33558", "a_Value"); // put some stuff in the collection - map33558.put("keyB-33558", param); // put it in a collection - map33558.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map33558.get("keyB-33558"); // get it back out - bar = (String) map33558.get("keyA-33558"); // get safe value back out - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00681.java b/OWASP DATASET CLEANED/BenchmarkTest00681.java deleted file mode 100644 index 49e5fa693e2406f6201169906c4bb99a9626cc28..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00681.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00681") -public class BenchmarkTest00681 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00681"); - if (param == null) param = ""; - - String bar = param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00682.java b/OWASP DATASET CLEANED/BenchmarkTest00682.java deleted file mode 100644 index a67b602fb5b480904dc54f8e58a51e1016cb64d4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00682.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00682") -public class BenchmarkTest00682 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00682"); - if (param == null) param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00683.java b/OWASP DATASET CLEANED/BenchmarkTest00683.java deleted file mode 100644 index 4dacc44a3b0f22f4e1c8151094766f4e520778c0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00683.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest00683") -public class BenchmarkTest00683 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest00683"); - if (param == null) param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00684.java b/OWASP DATASET CLEANED/BenchmarkTest00684.java deleted file mode 100644 index 20713c9a1171cd7b15dfb04ee53b7699f864dab0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00684.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00684") -public class BenchmarkTest00684 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00684"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00685.java b/OWASP DATASET CLEANED/BenchmarkTest00685.java deleted file mode 100644 index b2785e53b3263df5cc53ba2e2a1fe88d2ce41f57..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00685.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00685") -public class BenchmarkTest00685 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00685"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz40853 = new StringBuilder(param); - bar = sbxyz40853.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00686.java b/OWASP DATASET CLEANED/BenchmarkTest00686.java deleted file mode 100644 index 08f515ad1e67d5472b8fb0ef8cfc7f6a9c550514..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00686.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00686") -public class BenchmarkTest00686 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00686"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00687.java b/OWASP DATASET CLEANED/BenchmarkTest00687.java deleted file mode 100644 index 827c52e27950cf526621db0d1e9e826938821a88..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00687.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00687") -public class BenchmarkTest00687 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00687"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00688.java b/OWASP DATASET CLEANED/BenchmarkTest00688.java deleted file mode 100644 index 458c53a0dda52b54a71d2dcd0efdd0461c8e674e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00688.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00688") -public class BenchmarkTest00688 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00688"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00689.java b/OWASP DATASET CLEANED/BenchmarkTest00689.java deleted file mode 100644 index 445de521f1f88e7d6765a52c9e768d0ff81a8f6b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00689.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00689") -public class BenchmarkTest00689 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00689"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - // Chain a bunch of propagators in sequence - String a98281 = param; // assign - StringBuilder b98281 = new StringBuilder(a98281); // stick in stringbuilder - b98281.append(" SafeStuff"); // append some safe content - b98281.replace( - b98281.length() - "Chars".length(), - b98281.length(), - "Chars"); // replace some of the end content - java.util.HashMap map98281 = new java.util.HashMap(); - map98281.put("key98281", b98281.toString()); // put in a collection - String c98281 = (String) map98281.get("key98281"); // get it back out - String d98281 = c98281.substring(0, c98281.length() - 1); // extract most of it - String e98281 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d98281.getBytes()))); // B64 encode and decode it - String f98281 = e98281.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g98281 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g98281); // reflection - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00690.java b/OWASP DATASET CLEANED/BenchmarkTest00690.java deleted file mode 100644 index 15e29b4595b48767d2f9b853ca7219225e48394d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00690.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00690") -public class BenchmarkTest00690 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00690"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00691.java b/OWASP DATASET CLEANED/BenchmarkTest00691.java deleted file mode 100644 index 56dce170a14f0572de11e6d52185d3c2b06bb755..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00691.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-00/BenchmarkTest00691") -public class BenchmarkTest00691 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00691"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00692.java b/OWASP DATASET CLEANED/BenchmarkTest00692.java deleted file mode 100644 index 6bb158b3c87eaca2e4b499f4f5678a1a8ed4e4a6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00692.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00692") -public class BenchmarkTest00692 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00692"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00693.java b/OWASP DATASET CLEANED/BenchmarkTest00693.java deleted file mode 100644 index 835ead317c3ed9288a5285aa29b50ccc4c87e34e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00693.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00693") -public class BenchmarkTest00693 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00693"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00694.java b/OWASP DATASET CLEANED/BenchmarkTest00694.java deleted file mode 100644 index 92eeeb0cf2dca8548ccecc95ec153b2077dd52e2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00694.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00694") -public class BenchmarkTest00694 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00694"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = param; - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00695.java b/OWASP DATASET CLEANED/BenchmarkTest00695.java deleted file mode 100644 index 02b814e3d5136ab88f1cb2f2c7552b39f95d8301..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00695.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00695") -public class BenchmarkTest00695 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00695"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map9400 = new java.util.HashMap(); - map9400.put("keyA-9400", "a-Value"); // put some stuff in the collection - map9400.put("keyB-9400", param); // put it in a collection - map9400.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map9400.get("keyB-9400"); // get it back out - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00696.java b/OWASP DATASET CLEANED/BenchmarkTest00696.java deleted file mode 100644 index c60f6bdf1d4dbae1df9b4eae95e5f0f4382c9ff7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00696.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00696") -public class BenchmarkTest00696 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00696"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00697.java b/OWASP DATASET CLEANED/BenchmarkTest00697.java deleted file mode 100644 index 806a59aab96f315680b44d10a39d7fb83a1f3404..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00697.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00697") -public class BenchmarkTest00697 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00697"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00698.java b/OWASP DATASET CLEANED/BenchmarkTest00698.java deleted file mode 100644 index 4fb641881f620b495337155f5620c571965e7c67..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00698.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00698") -public class BenchmarkTest00698 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00698"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00699.java b/OWASP DATASET CLEANED/BenchmarkTest00699.java deleted file mode 100644 index 57a88dac4f79e6532f4b518d77511aeaca5f3ee5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00699.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00699") -public class BenchmarkTest00699 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00699"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00700.java b/OWASP DATASET CLEANED/BenchmarkTest00700.java deleted file mode 100644 index 9980880cb52825294550a745c0ebcd4e7d9b521b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00700.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00700") -public class BenchmarkTest00700 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00700"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00701.java b/OWASP DATASET CLEANED/BenchmarkTest00701.java deleted file mode 100644 index 872835ece40076e969c63bcea9489816830c2c2e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00701.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00701") -public class BenchmarkTest00701 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00701"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - // Chain a bunch of propagators in sequence - String a85232 = param; // assign - StringBuilder b85232 = new StringBuilder(a85232); // stick in stringbuilder - b85232.append(" SafeStuff"); // append some safe content - b85232.replace( - b85232.length() - "Chars".length(), - b85232.length(), - "Chars"); // replace some of the end content - java.util.HashMap map85232 = new java.util.HashMap(); - map85232.put("key85232", b85232.toString()); // put in a collection - String c85232 = (String) map85232.get("key85232"); // get it back out - String d85232 = c85232.substring(0, c85232.length() - 1); // extract most of it - String e85232 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d85232.getBytes()))); // B64 encode and decode it - String f85232 = e85232.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g85232 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g85232); // reflection - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00702.java b/OWASP DATASET CLEANED/BenchmarkTest00702.java deleted file mode 100644 index 364ee86a3902ccbd954247eae9a4a3c616e604da..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00702.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00702") -public class BenchmarkTest00702 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00702"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00703.java b/OWASP DATASET CLEANED/BenchmarkTest00703.java deleted file mode 100644 index b06e6733459c7902f4b29aa908110bcb3c997397..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00703.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00703") -public class BenchmarkTest00703 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00703"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00704.java b/OWASP DATASET CLEANED/BenchmarkTest00704.java deleted file mode 100644 index e0518469eda2bced4c0c87461ed8bde21f6c9e49..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00704.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00704") -public class BenchmarkTest00704 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00704"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00705.java b/OWASP DATASET CLEANED/BenchmarkTest00705.java deleted file mode 100644 index 0061edc6d5d593490d9f11bf0978028012c29f0d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00705.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00705") -public class BenchmarkTest00705 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00705"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map71551 = new java.util.HashMap(); - map71551.put("keyA-71551", "a_Value"); // put some stuff in the collection - map71551.put("keyB-71551", param); // put it in a collection - map71551.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map71551.get("keyB-71551"); // get it back out - bar = (String) map71551.get("keyA-71551"); // get safe value back out - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00706.java b/OWASP DATASET CLEANED/BenchmarkTest00706.java deleted file mode 100644 index 7bf740d404a18d77144d10a4e402ab9cb47deb42..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00706.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00706") -public class BenchmarkTest00706 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00706"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00707.java b/OWASP DATASET CLEANED/BenchmarkTest00707.java deleted file mode 100644 index c525f885f8fbc7b84d903088ce82b73cd4f91832..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00707.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00707") -public class BenchmarkTest00707 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00707"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00708.java b/OWASP DATASET CLEANED/BenchmarkTest00708.java deleted file mode 100644 index edb90ae601207e79b5decf172d845d9194e655a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00708.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00708") -public class BenchmarkTest00708 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00708"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00709.java b/OWASP DATASET CLEANED/BenchmarkTest00709.java deleted file mode 100644 index 58409ab8e5046f26be16f89f18ef9fa9937564df..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00709.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00709") -public class BenchmarkTest00709 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00709"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00710.java b/OWASP DATASET CLEANED/BenchmarkTest00710.java deleted file mode 100644 index bfe93a0bc6bfd33f54032510918bb29628090887..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00710.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00710") -public class BenchmarkTest00710 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00710"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00711.java b/OWASP DATASET CLEANED/BenchmarkTest00711.java deleted file mode 100644 index 006ca7adaaab63b70a4c61775d92535ed24718e2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00711.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00711") -public class BenchmarkTest00711 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00711"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00712.java b/OWASP DATASET CLEANED/BenchmarkTest00712.java deleted file mode 100644 index dc390fc2d13785858f7ed0901fc68e2bd199d554..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00712.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00712") -public class BenchmarkTest00712 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00712"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00713.java b/OWASP DATASET CLEANED/BenchmarkTest00713.java deleted file mode 100644 index 179844423f079e0d511c43875749e58bac0a40db..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00713.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00713") -public class BenchmarkTest00713 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00713"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00714.java b/OWASP DATASET CLEANED/BenchmarkTest00714.java deleted file mode 100644 index 025e9ecadfeb20ae338dab393c719b996dcd7854..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00714.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00714") -public class BenchmarkTest00714 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00714"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00715.java b/OWASP DATASET CLEANED/BenchmarkTest00715.java deleted file mode 100644 index b85d505869f562aa3c5c84ed90765853d1c18f3e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00715.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00715") -public class BenchmarkTest00715 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00715"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00716.java b/OWASP DATASET CLEANED/BenchmarkTest00716.java deleted file mode 100644 index b7646759c6c5422af4d78b2f364d9a545c3af267..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00716.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00716") -public class BenchmarkTest00716 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00716"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00717.java b/OWASP DATASET CLEANED/BenchmarkTest00717.java deleted file mode 100644 index 4f5b43b440e38eabaaa173853d59a49065757d5d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00717.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00717") -public class BenchmarkTest00717 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00717"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - // Chain a bunch of propagators in sequence - String a59129 = param; // assign - StringBuilder b59129 = new StringBuilder(a59129); // stick in stringbuilder - b59129.append(" SafeStuff"); // append some safe content - b59129.replace( - b59129.length() - "Chars".length(), - b59129.length(), - "Chars"); // replace some of the end content - java.util.HashMap map59129 = new java.util.HashMap(); - map59129.put("key59129", b59129.toString()); // put in a collection - String c59129 = (String) map59129.get("key59129"); // get it back out - String d59129 = c59129.substring(0, c59129.length() - 1); // extract most of it - String e59129 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d59129.getBytes()))); // B64 encode and decode it - String f59129 = e59129.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g59129 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g59129); // reflection - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00718.java b/OWASP DATASET CLEANED/BenchmarkTest00718.java deleted file mode 100644 index 23c73256066f5b17bfbc21956365cf62a5866105..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00718.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00718") -public class BenchmarkTest00718 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00718"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00719.java b/OWASP DATASET CLEANED/BenchmarkTest00719.java deleted file mode 100644 index 8692ecbe1e8d1654029ac753af49952afa9f19dd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00719.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00719") -public class BenchmarkTest00719 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00719"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00720.java b/OWASP DATASET CLEANED/BenchmarkTest00720.java deleted file mode 100644 index b5b11fe8d25c9726f47355dab71dccce7fc397bd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00720.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00720") -public class BenchmarkTest00720 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00720"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00721.java b/OWASP DATASET CLEANED/BenchmarkTest00721.java deleted file mode 100644 index 4feb307da11745e4584a8a24d1eea97e4a7554e2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00721.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00721") -public class BenchmarkTest00721 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00721"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00722.java b/OWASP DATASET CLEANED/BenchmarkTest00722.java deleted file mode 100644 index a587010ac0eb7ee043d679c639c8e6bb92da335b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00722.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00722") -public class BenchmarkTest00722 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00722"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map49442 = new java.util.HashMap(); - map49442.put("keyA-49442", "a_Value"); // put some stuff in the collection - map49442.put("keyB-49442", param); // put it in a collection - map49442.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map49442.get("keyB-49442"); // get it back out - bar = (String) map49442.get("keyA-49442"); // get safe value back out - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00723.java b/OWASP DATASET CLEANED/BenchmarkTest00723.java deleted file mode 100644 index 9d0179e3c3766a33f1fee6c46b9c917eb0f9c043..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00723.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00723") -public class BenchmarkTest00723 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00723"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00724.java b/OWASP DATASET CLEANED/BenchmarkTest00724.java deleted file mode 100644 index 0ead59464d167d94b4a73cb4a102536b42d63f1c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00724.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00724") -public class BenchmarkTest00724 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00724"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00725.java b/OWASP DATASET CLEANED/BenchmarkTest00725.java deleted file mode 100644 index 2a128b742dbafcb0da0afbcdebcef973784e70d0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00725.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00725") -public class BenchmarkTest00725 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00725"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - // Chain a bunch of propagators in sequence - String a49441 = param; // assign - StringBuilder b49441 = new StringBuilder(a49441); // stick in stringbuilder - b49441.append(" SafeStuff"); // append some safe content - b49441.replace( - b49441.length() - "Chars".length(), - b49441.length(), - "Chars"); // replace some of the end content - java.util.HashMap map49441 = new java.util.HashMap(); - map49441.put("key49441", b49441.toString()); // put in a collection - String c49441 = (String) map49441.get("key49441"); // get it back out - String d49441 = c49441.substring(0, c49441.length() - 1); // extract most of it - String e49441 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d49441.getBytes()))); // B64 encode and decode it - String f49441 = e49441.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f49441); // reflection - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00726.java b/OWASP DATASET CLEANED/BenchmarkTest00726.java deleted file mode 100644 index 00f7c7af9a5f6ad7e1c44ce1ee670ad4c2be4d72..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00726.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00726") -public class BenchmarkTest00726 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00726"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00727.java b/OWASP DATASET CLEANED/BenchmarkTest00727.java deleted file mode 100644 index c8a7f358f11db7a854905cc59c584c4e72c8ca91..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00727.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00727") -public class BenchmarkTest00727 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00727"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00728.java b/OWASP DATASET CLEANED/BenchmarkTest00728.java deleted file mode 100644 index d6df56ca991700e016e5eb94592c46ea843f8482..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00728.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00728") -public class BenchmarkTest00728 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00728"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00729.java b/OWASP DATASET CLEANED/BenchmarkTest00729.java deleted file mode 100644 index 3f299aa023a8f51a7318fb22f6d7dd8e1c58183a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00729.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00729") -public class BenchmarkTest00729 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00729"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00730.java b/OWASP DATASET CLEANED/BenchmarkTest00730.java deleted file mode 100644 index 87eba9b95436e8d656b1897c58a3dcabe8061dde..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00730.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00730") -public class BenchmarkTest00730 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00730"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map29173 = new java.util.HashMap(); - map29173.put("keyA-29173", "a_Value"); // put some stuff in the collection - map29173.put("keyB-29173", param); // put it in a collection - map29173.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map29173.get("keyB-29173"); // get it back out - bar = (String) map29173.get("keyA-29173"); // get safe value back out - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00731.java b/OWASP DATASET CLEANED/BenchmarkTest00731.java deleted file mode 100644 index 045b4f565f378ae7d661bdf77d074e2d6c66ece6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00731.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00731") -public class BenchmarkTest00731 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00731"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = param; - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00732.java b/OWASP DATASET CLEANED/BenchmarkTest00732.java deleted file mode 100644 index 63e4278a13a58da1c2009488973e0c4bba1539d0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00732.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00732") -public class BenchmarkTest00732 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00732"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map99333 = new java.util.HashMap(); - map99333.put("keyA-99333", "a_Value"); // put some stuff in the collection - map99333.put("keyB-99333", param); // put it in a collection - map99333.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map99333.get("keyB-99333"); // get it back out - bar = (String) map99333.get("keyA-99333"); // get safe value back out - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00733.java b/OWASP DATASET CLEANED/BenchmarkTest00733.java deleted file mode 100644 index d797ca21c2f3f8992d3496c84ccc9415350c0a8d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00733.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00733") -public class BenchmarkTest00733 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00733"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - StringBuilder sbxyz15959 = new StringBuilder(param); - String bar = sbxyz15959.append("_SafeStuff").toString(); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00734.java b/OWASP DATASET CLEANED/BenchmarkTest00734.java deleted file mode 100644 index 45787c8952c25ff6b3c0506a3b4e3e112889388a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00734.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00734") -public class BenchmarkTest00734 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00734"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00735.java b/OWASP DATASET CLEANED/BenchmarkTest00735.java deleted file mode 100644 index 9b9aa1463be58deb1ab5b9e7fd908045440a26cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00735.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00735") -public class BenchmarkTest00735 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00735"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00736.java b/OWASP DATASET CLEANED/BenchmarkTest00736.java deleted file mode 100644 index 69b7d39d5cd948f8fb73c764d64bc9084fb78365..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00736.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00736") -public class BenchmarkTest00736 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00736"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00737.java b/OWASP DATASET CLEANED/BenchmarkTest00737.java deleted file mode 100644 index 06b8d07a4bdd632ce8bf6a2a2ad20791644cc321..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00737.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00737") -public class BenchmarkTest00737 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00737"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - // Chain a bunch of propagators in sequence - String a57334 = param; // assign - StringBuilder b57334 = new StringBuilder(a57334); // stick in stringbuilder - b57334.append(" SafeStuff"); // append some safe content - b57334.replace( - b57334.length() - "Chars".length(), - b57334.length(), - "Chars"); // replace some of the end content - java.util.HashMap map57334 = new java.util.HashMap(); - map57334.put("key57334", b57334.toString()); // put in a collection - String c57334 = (String) map57334.get("key57334"); // get it back out - String d57334 = c57334.substring(0, c57334.length() - 1); // extract most of it - String e57334 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d57334.getBytes()))); // B64 encode and decode it - String f57334 = e57334.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f57334); // reflection - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00738.java b/OWASP DATASET CLEANED/BenchmarkTest00738.java deleted file mode 100644 index 71fecd2be284c3180d4be620811d066148c83d78..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00738.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00738") -public class BenchmarkTest00738 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00738"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00739.java b/OWASP DATASET CLEANED/BenchmarkTest00739.java deleted file mode 100644 index 86107cf26d4a60bdf4bdac7e4a44b2be319b4376..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00739.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00739") -public class BenchmarkTest00739 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00739"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00740.java b/OWASP DATASET CLEANED/BenchmarkTest00740.java deleted file mode 100644 index 6c39f06a0cb222bc7fcd6ccfc01e04af4efe2c6c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00740.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00740") -public class BenchmarkTest00740 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00740"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map87432 = new java.util.HashMap(); - map87432.put("keyA-87432", "a-Value"); // put some stuff in the collection - map87432.put("keyB-87432", param); // put it in a collection - map87432.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map87432.get("keyB-87432"); // get it back out - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00741.java b/OWASP DATASET CLEANED/BenchmarkTest00741.java deleted file mode 100644 index 7ca68bdfc504383f0879c9f7e314c2e1dfd23b22..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00741.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00741") -public class BenchmarkTest00741 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00741"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00742.java b/OWASP DATASET CLEANED/BenchmarkTest00742.java deleted file mode 100644 index 1ceed6d068ef79dce10b6f8d266535e1e1605b1b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00742.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00742") -public class BenchmarkTest00742 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00742"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map62435 = new java.util.HashMap(); - map62435.put("keyA-62435", "a_Value"); // put some stuff in the collection - map62435.put("keyB-62435", param); // put it in a collection - map62435.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map62435.get("keyB-62435"); // get it back out - bar = (String) map62435.get("keyA-62435"); // get safe value back out - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00743.java b/OWASP DATASET CLEANED/BenchmarkTest00743.java deleted file mode 100644 index b5f7b09dc7d471100e0ee155805923655561b09f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00743.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00743") -public class BenchmarkTest00743 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00743"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00744.java b/OWASP DATASET CLEANED/BenchmarkTest00744.java deleted file mode 100644 index ef219a7802a6f679f6d6d7efca0f716058ae109f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00744.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00744") -public class BenchmarkTest00744 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00744"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00745.java b/OWASP DATASET CLEANED/BenchmarkTest00745.java deleted file mode 100644 index 734c337ab6f59b0f077d9b6a586a02aec6819da1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00745.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00745") -public class BenchmarkTest00745 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00745"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00746.java b/OWASP DATASET CLEANED/BenchmarkTest00746.java deleted file mode 100644 index 03577a6befe0fca20de24219aeabb18bf6922da3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00746.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00746") -public class BenchmarkTest00746 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00746"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00747.java b/OWASP DATASET CLEANED/BenchmarkTest00747.java deleted file mode 100644 index 5a47fcd1dd78f26e0f433fae2badb91867a093e7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00747.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00747") -public class BenchmarkTest00747 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00747"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00748.java b/OWASP DATASET CLEANED/BenchmarkTest00748.java deleted file mode 100644 index 5607de3123c27bc462c82deaadbc3ec315541a4f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00748.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00748") -public class BenchmarkTest00748 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00748"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - // Chain a bunch of propagators in sequence - String a43085 = param; // assign - StringBuilder b43085 = new StringBuilder(a43085); // stick in stringbuilder - b43085.append(" SafeStuff"); // append some safe content - b43085.replace( - b43085.length() - "Chars".length(), - b43085.length(), - "Chars"); // replace some of the end content - java.util.HashMap map43085 = new java.util.HashMap(); - map43085.put("key43085", b43085.toString()); // put in a collection - String c43085 = (String) map43085.get("key43085"); // get it back out - String d43085 = c43085.substring(0, c43085.length() - 1); // extract most of it - String e43085 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d43085.getBytes()))); // B64 encode and decode it - String f43085 = e43085.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g43085 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g43085); // reflection - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00749.java b/OWASP DATASET CLEANED/BenchmarkTest00749.java deleted file mode 100644 index 5c05aa6216baad1ae4e0eec11f24a8a932ea2cab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00749.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00749") -public class BenchmarkTest00749 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00749"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - StringBuilder sbxyz94097 = new StringBuilder(param); - String bar = sbxyz94097.append("_SafeStuff").toString(); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00750.java b/OWASP DATASET CLEANED/BenchmarkTest00750.java deleted file mode 100644 index 7de857a34f1b0603a986cef67ff592bca7720e84..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00750.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00750") -public class BenchmarkTest00750 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00750"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz18731 = new StringBuilder(param); - bar = sbxyz18731.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00751.java b/OWASP DATASET CLEANED/BenchmarkTest00751.java deleted file mode 100644 index 49db4aa7e3dda50be21cdeecd8311e67c918d94b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00751.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00751") -public class BenchmarkTest00751 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00751"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00752.java b/OWASP DATASET CLEANED/BenchmarkTest00752.java deleted file mode 100644 index ca5327ef658d5be85562222fc24c2668c37a8988..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00752.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00752") -public class BenchmarkTest00752 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00752"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00753.java b/OWASP DATASET CLEANED/BenchmarkTest00753.java deleted file mode 100644 index a68df1e18c166ac06bd7f350259c56c9efcebfd8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00753.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00753") -public class BenchmarkTest00753 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00753"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00754.java b/OWASP DATASET CLEANED/BenchmarkTest00754.java deleted file mode 100644 index e4b1205732cfab4836be47901612af812f8037b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00754.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00754") -public class BenchmarkTest00754 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00754"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map6425 = new java.util.HashMap(); - map6425.put("keyA-6425", "a-Value"); // put some stuff in the collection - map6425.put("keyB-6425", param); // put it in a collection - map6425.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map6425.get("keyB-6425"); // get it back out - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00755.java b/OWASP DATASET CLEANED/BenchmarkTest00755.java deleted file mode 100644 index 8ed608b6c2da4c8f52de58fbcd65ff444c4400dd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00755.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00755") -public class BenchmarkTest00755 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00755"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00756.java b/OWASP DATASET CLEANED/BenchmarkTest00756.java deleted file mode 100644 index 8c0dbb8f706ddd816e1df55c4e351b4cc1395349..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00756.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00756") -public class BenchmarkTest00756 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00756"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00757.java b/OWASP DATASET CLEANED/BenchmarkTest00757.java deleted file mode 100644 index 1ac2f8cd2741a0aeb3eb06da551b1031c4bb6517..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00757.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00757") -public class BenchmarkTest00757 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00757"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00758.java b/OWASP DATASET CLEANED/BenchmarkTest00758.java deleted file mode 100644 index 1f089fa7107779221e2a85c9704aa89580fadac0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00758.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00758") -public class BenchmarkTest00758 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00758"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00759.java b/OWASP DATASET CLEANED/BenchmarkTest00759.java deleted file mode 100644 index 07a650eafd0cbfd2f9f7f2a56637fdd264292ba6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00759.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00759") -public class BenchmarkTest00759 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00759"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00760.java b/OWASP DATASET CLEANED/BenchmarkTest00760.java deleted file mode 100644 index bd35513af149a4e932c052279105247c9565d425..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00760.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00760") -public class BenchmarkTest00760 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00760"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map18915 = new java.util.HashMap(); - map18915.put("keyA-18915", "a-Value"); // put some stuff in the collection - map18915.put("keyB-18915", param); // put it in a collection - map18915.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map18915.get("keyB-18915"); // get it back out - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00761.java b/OWASP DATASET CLEANED/BenchmarkTest00761.java deleted file mode 100644 index c9be8a029157a03c3fa9fe8fa1a41eb6e0fe52f0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00761.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00761") -public class BenchmarkTest00761 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00761"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00762.java b/OWASP DATASET CLEANED/BenchmarkTest00762.java deleted file mode 100644 index 74259017a83390ff84b70a47a65da0ab941442e6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00762.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00762") -public class BenchmarkTest00762 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00762"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00763.java b/OWASP DATASET CLEANED/BenchmarkTest00763.java deleted file mode 100644 index c4157404068c90668ede04e7f411851112f9137a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00763.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00763") -public class BenchmarkTest00763 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00763"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new int[] {1, 2}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00764.java b/OWASP DATASET CLEANED/BenchmarkTest00764.java deleted file mode 100644 index 3e16ab6892e8099c49dad7000e0edf2f4432f83f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00764.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00764") -public class BenchmarkTest00764 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00764"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = param; - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00765.java b/OWASP DATASET CLEANED/BenchmarkTest00765.java deleted file mode 100644 index 3144ac8a20d3b8e26631703185b7a238b5905347..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00765.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00765") -public class BenchmarkTest00765 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00765"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00766.java b/OWASP DATASET CLEANED/BenchmarkTest00766.java deleted file mode 100644 index 0f190ad38c065795e32de35e84cc89e5ac278d17..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00766.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00766") -public class BenchmarkTest00766 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00766"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00767.java b/OWASP DATASET CLEANED/BenchmarkTest00767.java deleted file mode 100644 index a8189188fd554b0c7f6930d689b5deef2df44a79..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00767.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00767") -public class BenchmarkTest00767 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00767"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00768.java b/OWASP DATASET CLEANED/BenchmarkTest00768.java deleted file mode 100644 index b0acb740bec648cff707afa37f317fda056121c4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00768.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00768") -public class BenchmarkTest00768 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00768"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00769.java b/OWASP DATASET CLEANED/BenchmarkTest00769.java deleted file mode 100644 index ca2e9bbfad92a11aeb0af2b31097c3a2cad667a6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00769.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00769") -public class BenchmarkTest00769 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00769"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map29572 = new java.util.HashMap(); - map29572.put("keyA-29572", "a-Value"); // put some stuff in the collection - map29572.put("keyB-29572", param); // put it in a collection - map29572.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map29572.get("keyB-29572"); // get it back out - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00770.java b/OWASP DATASET CLEANED/BenchmarkTest00770.java deleted file mode 100644 index 8a01f043689da04d55d88b9f31f3fd813b856300..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00770.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00770") -public class BenchmarkTest00770 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00770"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00771.java b/OWASP DATASET CLEANED/BenchmarkTest00771.java deleted file mode 100644 index fd8d7c3f4253f9927abef63c7c669cc9dfa5ba1f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00771.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00771") -public class BenchmarkTest00771 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00771"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "safe!"; - java.util.HashMap map49960 = new java.util.HashMap(); - map49960.put("keyA-49960", "a-Value"); // put some stuff in the collection - map49960.put("keyB-49960", param); // put it in a collection - map49960.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map49960.get("keyB-49960"); // get it back out - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00772.java b/OWASP DATASET CLEANED/BenchmarkTest00772.java deleted file mode 100644 index e119ad0711dfcba685eb13cf6b12ce11211249fc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00772.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00772") -public class BenchmarkTest00772 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00772"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00773.java b/OWASP DATASET CLEANED/BenchmarkTest00773.java deleted file mode 100644 index 0968a1c07305c5da98a6a541415f05350ce01b15..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00773.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00773") -public class BenchmarkTest00773 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00773"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00774.java b/OWASP DATASET CLEANED/BenchmarkTest00774.java deleted file mode 100644 index 6b9f44e6b910bec1e3b7c244a91e58fe3a4c15a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00774.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00774") -public class BenchmarkTest00774 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest00774"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00775.java b/OWASP DATASET CLEANED/BenchmarkTest00775.java deleted file mode 100644 index eb9c740e44ce1c7e41583fc4eb7b653ea2e64228..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00775.java +++ /dev/null @@ -1,183 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00775") -public class BenchmarkTest00775 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00775" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00775" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00775" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00776.java b/OWASP DATASET CLEANED/BenchmarkTest00776.java deleted file mode 100644 index a9e92ba0e01314a973dbe10dc2e2ce3557f10ad9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00776.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00776") -public class BenchmarkTest00776 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00776" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00776" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00776" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00777.java b/OWASP DATASET CLEANED/BenchmarkTest00777.java deleted file mode 100644 index fe03f8c4ccd042c7a32293314ecc2bd7462c3ff9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00777.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00777") -public class BenchmarkTest00777 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00777" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00777" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00777" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map4544 = new java.util.HashMap(); - map4544.put("keyA-4544", "a_Value"); // put some stuff in the collection - map4544.put("keyB-4544", param); // put it in a collection - map4544.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map4544.get("keyB-4544"); // get it back out - bar = (String) map4544.get("keyA-4544"); // get safe value back out - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00778.java b/OWASP DATASET CLEANED/BenchmarkTest00778.java deleted file mode 100644 index 40c9314b944b70064b0e9043058f184930dde450..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00778.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00778") -public class BenchmarkTest00778 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00778" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00778" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00778" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00779.java b/OWASP DATASET CLEANED/BenchmarkTest00779.java deleted file mode 100644 index 1326ed1f866e7130f234f04d82af293cf62dc243..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00779.java +++ /dev/null @@ -1,176 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00779") -public class BenchmarkTest00779 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00779" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00779" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00779" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00780.java b/OWASP DATASET CLEANED/BenchmarkTest00780.java deleted file mode 100644 index 4848a707c55617868c2fcdc98c3d59c61f23952a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00780.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00780") -public class BenchmarkTest00780 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00780" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00780" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00780" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00781.java b/OWASP DATASET CLEANED/BenchmarkTest00781.java deleted file mode 100644 index 9ec14d9a281eae004b1f24fe29444ccd28d3c28e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00781.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00781") -public class BenchmarkTest00781 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00781" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00781" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00781" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00782.java b/OWASP DATASET CLEANED/BenchmarkTest00782.java deleted file mode 100644 index fde8cf9d3cd75ad96e6a154eb22a7a1077f142f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00782.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00782") -public class BenchmarkTest00782 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00782" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00782" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00782" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00783.java b/OWASP DATASET CLEANED/BenchmarkTest00783.java deleted file mode 100644 index bae0cc22a079ca805b247da6876b7a9121fac606..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00783.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00783") -public class BenchmarkTest00783 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00783" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00783" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00783" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map2299 = new java.util.HashMap(); - map2299.put("keyA-2299", "a-Value"); // put some stuff in the collection - map2299.put("keyB-2299", param); // put it in a collection - map2299.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map2299.get("keyB-2299"); // get it back out - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00784.java b/OWASP DATASET CLEANED/BenchmarkTest00784.java deleted file mode 100644 index a9c6f93f8274af47ee807e71b162363a165069ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00784.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00784") -public class BenchmarkTest00784 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00784" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00784" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00784" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00785.java b/OWASP DATASET CLEANED/BenchmarkTest00785.java deleted file mode 100644 index 7dfcbee2e84911b1a0e7a22f2c3533ba489857cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00785.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00785") -public class BenchmarkTest00785 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00785" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00785" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00785" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map59480 = new java.util.HashMap(); - map59480.put("keyA-59480", "a-Value"); // put some stuff in the collection - map59480.put("keyB-59480", param); // put it in a collection - map59480.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map59480.get("keyB-59480"); // get it back out - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00786.java b/OWASP DATASET CLEANED/BenchmarkTest00786.java deleted file mode 100644 index 9a004e3c20ae134646dcc8472927b46ae7da78c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00786.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00786") -public class BenchmarkTest00786 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00786" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00786" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00786" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map29957 = new java.util.HashMap(); - map29957.put("keyA-29957", "a_Value"); // put some stuff in the collection - map29957.put("keyB-29957", param); // put it in a collection - map29957.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map29957.get("keyB-29957"); // get it back out - bar = (String) map29957.get("keyA-29957"); // get safe value back out - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00787.java b/OWASP DATASET CLEANED/BenchmarkTest00787.java deleted file mode 100644 index a2adf6a9a693c00d6d03ecbfcb5f4cc6da426506..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00787.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00787") -public class BenchmarkTest00787 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00787" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00787" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00787" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00788.java b/OWASP DATASET CLEANED/BenchmarkTest00788.java deleted file mode 100644 index 170dde74b55d134321e940b58ff38fe6911ccd04..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00788.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00788") -public class BenchmarkTest00788 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00788" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00788" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00788" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00789.java b/OWASP DATASET CLEANED/BenchmarkTest00789.java deleted file mode 100644 index e674b769a5f55e7938044c97754d31bbe07fa6b7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00789.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00789") -public class BenchmarkTest00789 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00789" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00789" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00789" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00790.java b/OWASP DATASET CLEANED/BenchmarkTest00790.java deleted file mode 100644 index 55019c50738d3badb02d635f30deed12ff066a35..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00790.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00790") -public class BenchmarkTest00790 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00790" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00790" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00790" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00791.java b/OWASP DATASET CLEANED/BenchmarkTest00791.java deleted file mode 100644 index bbfe4cc649c7d038fa8d2f0f5337be815926fef7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00791.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00791") -public class BenchmarkTest00791 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00791" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00791" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00791" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00792.java b/OWASP DATASET CLEANED/BenchmarkTest00792.java deleted file mode 100644 index 47cd8bfebb46ce7612f8c154ad44b2b5ba1b32ff..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00792.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00792") -public class BenchmarkTest00792 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00792" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00792" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00792" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map53005 = new java.util.HashMap(); - map53005.put("keyA-53005", "a_Value"); // put some stuff in the collection - map53005.put("keyB-53005", param); // put it in a collection - map53005.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map53005.get("keyB-53005"); // get it back out - bar = (String) map53005.get("keyA-53005"); // get safe value back out - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00793.java b/OWASP DATASET CLEANED/BenchmarkTest00793.java deleted file mode 100644 index 5a0d5c22697639f6499505a12bca0d5b5affb88a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00793.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00793") -public class BenchmarkTest00793 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00793" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00793" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00793" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00794.java b/OWASP DATASET CLEANED/BenchmarkTest00794.java deleted file mode 100644 index b8c2e2a93ce4dc5d8aa28cb69286065eb2494ec7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00794.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00794") -public class BenchmarkTest00794 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00794" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00794" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00794" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00795.java b/OWASP DATASET CLEANED/BenchmarkTest00795.java deleted file mode 100644 index 9f62a6ff4e6945c8e73d602f22519f59bddaa6bc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00795.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00795") -public class BenchmarkTest00795 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00795" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00795" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00795" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00796.java b/OWASP DATASET CLEANED/BenchmarkTest00796.java deleted file mode 100644 index 49dcdcca32b9fe9878591d584890cf2195c15863..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00796.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-00/BenchmarkTest00796") -public class BenchmarkTest00796 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00796" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00796" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00796" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map72213 = new java.util.HashMap(); - map72213.put("keyA-72213", "a-Value"); // put some stuff in the collection - map72213.put("keyB-72213", param); // put it in a collection - map72213.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map72213.get("keyB-72213"); // get it back out - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00797.java b/OWASP DATASET CLEANED/BenchmarkTest00797.java deleted file mode 100644 index c4255758e31234bdb9dab4b81e1dc822413f928a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00797.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00797") -public class BenchmarkTest00797 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00797" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00797" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00797" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz97281 = new StringBuilder(param); - bar = sbxyz97281.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00798.java b/OWASP DATASET CLEANED/BenchmarkTest00798.java deleted file mode 100644 index c1f5845191f6a4ca03c830401b7b47ef01528907..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00798.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00798") -public class BenchmarkTest00798 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00798" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00798" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00798" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz25489 = new StringBuilder(param); - bar = sbxyz25489.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00799.java b/OWASP DATASET CLEANED/BenchmarkTest00799.java deleted file mode 100644 index 52a7c5f6536fb9c973851ed876a1ac9a9cba92d7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00799.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00799") -public class BenchmarkTest00799 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00799" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00799" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00799" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00800.java b/OWASP DATASET CLEANED/BenchmarkTest00800.java deleted file mode 100644 index 3bc52c19cc68f3b6ddfb77d15d86df800e5a2267..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00800.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00800") -public class BenchmarkTest00800 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00800" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00800" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00800" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00801.java b/OWASP DATASET CLEANED/BenchmarkTest00801.java deleted file mode 100644 index 1b775cbbe93206163fbe37e370e5acd592ef3f83..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00801.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00801") -public class BenchmarkTest00801 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00801" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00801" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00801" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00802.java b/OWASP DATASET CLEANED/BenchmarkTest00802.java deleted file mode 100644 index 90c1b770a83cf6067f952d59e1e7207f270630ac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00802.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00802") -public class BenchmarkTest00802 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00802" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00802" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00802" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00803.java b/OWASP DATASET CLEANED/BenchmarkTest00803.java deleted file mode 100644 index adb0736ba27f295600c751b17b0cb95d6041d935..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00803.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00803") -public class BenchmarkTest00803 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00803" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00803" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00803" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00804.java b/OWASP DATASET CLEANED/BenchmarkTest00804.java deleted file mode 100644 index 98dff6eb81ce4568f249177ddc4c9bdc7469f22c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00804.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00804") -public class BenchmarkTest00804 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00804" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00804" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00804" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - StringBuilder sbxyz12823 = new StringBuilder(param); - String bar = sbxyz12823.append("_SafeStuff").toString(); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00805.java b/OWASP DATASET CLEANED/BenchmarkTest00805.java deleted file mode 100644 index 8e32dbd8c1fef2962950c51d9a760f72572f581c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00805.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00805") -public class BenchmarkTest00805 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00805" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00805" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00805" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a72616 = param; // assign - StringBuilder b72616 = new StringBuilder(a72616); // stick in stringbuilder - b72616.append(" SafeStuff"); // append some safe content - b72616.replace( - b72616.length() - "Chars".length(), - b72616.length(), - "Chars"); // replace some of the end content - java.util.HashMap map72616 = new java.util.HashMap(); - map72616.put("key72616", b72616.toString()); // put in a collection - String c72616 = (String) map72616.get("key72616"); // get it back out - String d72616 = c72616.substring(0, c72616.length() - 1); // extract most of it - String e72616 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d72616.getBytes()))); // B64 encode and decode it - String f72616 = e72616.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f72616); // reflection - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00806.java b/OWASP DATASET CLEANED/BenchmarkTest00806.java deleted file mode 100644 index eb54a60cebab616981d2ecca31f7a8c0c52d7bb3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00806.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00806") -public class BenchmarkTest00806 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00806" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00806" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00806" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00807.java b/OWASP DATASET CLEANED/BenchmarkTest00807.java deleted file mode 100644 index aedb712a13d3efab35a92b3a263fb264205d82fc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00807.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00807") -public class BenchmarkTest00807 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00807" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00807" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00807" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00808.java b/OWASP DATASET CLEANED/BenchmarkTest00808.java deleted file mode 100644 index 727ae9459de22606d5272dc63e3bac6ced1c9993..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00808.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00808") -public class BenchmarkTest00808 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00808" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00808" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00808" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00809.java b/OWASP DATASET CLEANED/BenchmarkTest00809.java deleted file mode 100644 index 3b1cd048bcc82a4fb9fb05555eb43213582fafda..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00809.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00809") -public class BenchmarkTest00809 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00809" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00809" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00809" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00810.java b/OWASP DATASET CLEANED/BenchmarkTest00810.java deleted file mode 100644 index 558e0bebf5cf93af7834f7b1ed7aff10666ec5c8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00810.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00810") -public class BenchmarkTest00810 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00810" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00810" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00810" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - StringBuilder sbxyz36624 = new StringBuilder(param); - String bar = sbxyz36624.append("_SafeStuff").toString(); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00811.java b/OWASP DATASET CLEANED/BenchmarkTest00811.java deleted file mode 100644 index 25e9a73467d59609140e2c8da3fc457988aec2f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00811.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00811") -public class BenchmarkTest00811 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00811" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00811" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00811" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00812.java b/OWASP DATASET CLEANED/BenchmarkTest00812.java deleted file mode 100644 index c160bcb183562d1c1493ee341e71b45952e68583..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00812.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00812") -public class BenchmarkTest00812 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00812" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00812" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00812" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00813.java b/OWASP DATASET CLEANED/BenchmarkTest00813.java deleted file mode 100644 index 6634dd55611b5d354d94e85d22c09e778bcbbc9c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00813.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00813") -public class BenchmarkTest00813 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00813" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00813" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00813" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00814.java b/OWASP DATASET CLEANED/BenchmarkTest00814.java deleted file mode 100644 index ea80dbc0d3e55adc1b9effb1aab0448340798451..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00814.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00814") -public class BenchmarkTest00814 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00814" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00814" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00814" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00815.java b/OWASP DATASET CLEANED/BenchmarkTest00815.java deleted file mode 100644 index 1148cd403dbe5f836e15d33116ba02fd8ebf5a37..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00815.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00815") -public class BenchmarkTest00815 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00815" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00815" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00815" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00816.java b/OWASP DATASET CLEANED/BenchmarkTest00816.java deleted file mode 100644 index eebb195025be2f864005fedc35ab43135cf48e28..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00816.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00816") -public class BenchmarkTest00816 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00816" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00816" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00816" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map34260 = new java.util.HashMap(); - map34260.put("keyA-34260", "a-Value"); // put some stuff in the collection - map34260.put("keyB-34260", param); // put it in a collection - map34260.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map34260.get("keyB-34260"); // get it back out - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00817.java b/OWASP DATASET CLEANED/BenchmarkTest00817.java deleted file mode 100644 index 0f44b17e3130bf9bd9f025334743f8e1ecfe8c1d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00817.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00817") -public class BenchmarkTest00817 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00817" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00817" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00817" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a9795 = param; // assign - StringBuilder b9795 = new StringBuilder(a9795); // stick in stringbuilder - b9795.append(" SafeStuff"); // append some safe content - b9795.replace( - b9795.length() - "Chars".length(), - b9795.length(), - "Chars"); // replace some of the end content - java.util.HashMap map9795 = new java.util.HashMap(); - map9795.put("key9795", b9795.toString()); // put in a collection - String c9795 = (String) map9795.get("key9795"); // get it back out - String d9795 = c9795.substring(0, c9795.length() - 1); // extract most of it - String e9795 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d9795.getBytes()))); // B64 encode and decode it - String f9795 = e9795.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f9795); // reflection - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00818.java b/OWASP DATASET CLEANED/BenchmarkTest00818.java deleted file mode 100644 index ec036e93d53ef82cb16bd925670567c0121d8aae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00818.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00818") -public class BenchmarkTest00818 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00818" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00818" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00818" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00819.java b/OWASP DATASET CLEANED/BenchmarkTest00819.java deleted file mode 100644 index 06d9a146b06e173fe0edbb91f552a81b859db2f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00819.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00819") -public class BenchmarkTest00819 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00819" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00819" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00819" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00820.java b/OWASP DATASET CLEANED/BenchmarkTest00820.java deleted file mode 100644 index 1443388284b1530365e61389f6fcf6d445351fa0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00820.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00820") -public class BenchmarkTest00820 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00820" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00820" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00820" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00821.java b/OWASP DATASET CLEANED/BenchmarkTest00821.java deleted file mode 100644 index c238de35bdbe0ea7234d135b5b4a50a553bbf450..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00821.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00821") -public class BenchmarkTest00821 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00821" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00821" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00821" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00822.java b/OWASP DATASET CLEANED/BenchmarkTest00822.java deleted file mode 100644 index 67f956bc12b8a1c238aec3ebce5da8d98a769b66..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00822.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00822") -public class BenchmarkTest00822 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00822" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00822" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00822" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00823.java b/OWASP DATASET CLEANED/BenchmarkTest00823.java deleted file mode 100644 index 21463d6be68a95b6cdc2924dd14f7fe8bc6829a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00823.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00823") -public class BenchmarkTest00823 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00823" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00823" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00823" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00824.java b/OWASP DATASET CLEANED/BenchmarkTest00824.java deleted file mode 100644 index 8c1fb2f0658ae0cf2e9488089198409533d2d3f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00824.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00824") -public class BenchmarkTest00824 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00824" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00824" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00824" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map57450 = new java.util.HashMap(); - map57450.put("keyA-57450", "a-Value"); // put some stuff in the collection - map57450.put("keyB-57450", param); // put it in a collection - map57450.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map57450.get("keyB-57450"); // get it back out - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00825.java b/OWASP DATASET CLEANED/BenchmarkTest00825.java deleted file mode 100644 index 047e1847bfa8275b089455b6ede4a416878ab1e1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00825.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00825") -public class BenchmarkTest00825 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00825" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00825" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00825" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00826.java b/OWASP DATASET CLEANED/BenchmarkTest00826.java deleted file mode 100644 index 031fd0626e21bbdd4480c1a4d9c40952315c9af4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00826.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00826") -public class BenchmarkTest00826 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00826" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00826" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00826" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00827.java b/OWASP DATASET CLEANED/BenchmarkTest00827.java deleted file mode 100644 index a75a3f546915f6fa986802c0c1fd84c3f3b82ca7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00827.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-00/BenchmarkTest00827") -public class BenchmarkTest00827 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00827" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00827" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00827" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00828.java b/OWASP DATASET CLEANED/BenchmarkTest00828.java deleted file mode 100644 index 56ab923439158e0e2d0ae839825835639ba8a90a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00828.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00828") -public class BenchmarkTest00828 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00828" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00828" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00828" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00829.java b/OWASP DATASET CLEANED/BenchmarkTest00829.java deleted file mode 100644 index 39314b5b6afc22bfe5ede81dbe73c6f9de39671d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00829.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00829") -public class BenchmarkTest00829 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00829" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00829" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00829" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00830.java b/OWASP DATASET CLEANED/BenchmarkTest00830.java deleted file mode 100644 index eb167247cf7791733aeb429f836cd45689cec728..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00830.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00830") -public class BenchmarkTest00830 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00830" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00830" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00830" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00831.java b/OWASP DATASET CLEANED/BenchmarkTest00831.java deleted file mode 100644 index 7287bc8f722387720feba154bc3638ce1ddf103a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00831.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00831") -public class BenchmarkTest00831 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00831" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00831" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00831" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - // Chain a bunch of propagators in sequence - String a97193 = param; // assign - StringBuilder b97193 = new StringBuilder(a97193); // stick in stringbuilder - b97193.append(" SafeStuff"); // append some safe content - b97193.replace( - b97193.length() - "Chars".length(), - b97193.length(), - "Chars"); // replace some of the end content - java.util.HashMap map97193 = new java.util.HashMap(); - map97193.put("key97193", b97193.toString()); // put in a collection - String c97193 = (String) map97193.get("key97193"); // get it back out - String d97193 = c97193.substring(0, c97193.length() - 1); // extract most of it - String e97193 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d97193.getBytes()))); // B64 encode and decode it - String f97193 = e97193.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g97193 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g97193); // reflection - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00832.java b/OWASP DATASET CLEANED/BenchmarkTest00832.java deleted file mode 100644 index 5253d462dea2df549e0c5de115e2d107b59202b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00832.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00832") -public class BenchmarkTest00832 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00832" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00832" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00832" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00833.java b/OWASP DATASET CLEANED/BenchmarkTest00833.java deleted file mode 100644 index 1e38d8b1f263a7e4fbf2d4dd8cffc886944780e9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00833.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00833") -public class BenchmarkTest00833 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00833" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00833" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00833" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00834.java b/OWASP DATASET CLEANED/BenchmarkTest00834.java deleted file mode 100644 index ee0b1f40bb5ae256b945f6544cc6e6e8492a7a18..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00834.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00834") -public class BenchmarkTest00834 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00834" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00834" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00834" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00835.java b/OWASP DATASET CLEANED/BenchmarkTest00835.java deleted file mode 100644 index 819846fbfceb6b6757835c8f7f0b908bd3a7d8cd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00835.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00835") -public class BenchmarkTest00835 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00835" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00835" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00835" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00836.java b/OWASP DATASET CLEANED/BenchmarkTest00836.java deleted file mode 100644 index 87a017aa4820fdc9d8245ac2412a49dca7cfe6b1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00836.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00836") -public class BenchmarkTest00836 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00836" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00836" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00836" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00837.java b/OWASP DATASET CLEANED/BenchmarkTest00837.java deleted file mode 100644 index bebe5de008414f13d521a64e6348bcafea6f0003..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00837.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00837") -public class BenchmarkTest00837 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00837" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00837" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00837" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map5936 = new java.util.HashMap(); - map5936.put("keyA-5936", "a_Value"); // put some stuff in the collection - map5936.put("keyB-5936", param); // put it in a collection - map5936.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map5936.get("keyB-5936"); // get it back out - bar = (String) map5936.get("keyA-5936"); // get safe value back out - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00838.java b/OWASP DATASET CLEANED/BenchmarkTest00838.java deleted file mode 100644 index fdb384be59d937959e996453e2f507471d3e1c79..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00838.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00838") -public class BenchmarkTest00838 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00838" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00838" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00838" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00839.java b/OWASP DATASET CLEANED/BenchmarkTest00839.java deleted file mode 100644 index 513c5cc6550306fd71d8cf040caae0f28d00fdcd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00839.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00839") -public class BenchmarkTest00839 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00839" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00839" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00839" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00840.java b/OWASP DATASET CLEANED/BenchmarkTest00840.java deleted file mode 100644 index 5d9c41032e56416209f3df29d5c6b9bfceca8484..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00840.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00840") -public class BenchmarkTest00840 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00840" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00840" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00840" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00841.java b/OWASP DATASET CLEANED/BenchmarkTest00841.java deleted file mode 100644 index e5aeb06d95411b27561e5a5ed75fe743b9566f6e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00841.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00841") -public class BenchmarkTest00841 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00841" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00841" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00841" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00842.java b/OWASP DATASET CLEANED/BenchmarkTest00842.java deleted file mode 100644 index cc11768ee6f29bcb5c3fbd1ca3b8f7a1338f9a26..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00842.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00842") -public class BenchmarkTest00842 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00842" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00842" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00842" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00843.java b/OWASP DATASET CLEANED/BenchmarkTest00843.java deleted file mode 100644 index 4fb1231c3119b65dd1da7c164123f12d9522fee5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00843.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00843") -public class BenchmarkTest00843 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00843" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00843" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00843" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map12983 = new java.util.HashMap(); - map12983.put("keyA-12983", "a-Value"); // put some stuff in the collection - map12983.put("keyB-12983", param); // put it in a collection - map12983.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map12983.get("keyB-12983"); // get it back out - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00844.java b/OWASP DATASET CLEANED/BenchmarkTest00844.java deleted file mode 100644 index ea003ae318736142f2e00e1f2882b901bdd24134..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00844.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00844") -public class BenchmarkTest00844 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00844" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00844" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00844" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00845.java b/OWASP DATASET CLEANED/BenchmarkTest00845.java deleted file mode 100644 index 69a8ea505fcee534396f4971eaa1b50f8bcc76b0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00845.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00845") -public class BenchmarkTest00845 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00845" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00845" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00845" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00846.java b/OWASP DATASET CLEANED/BenchmarkTest00846.java deleted file mode 100644 index c0e6060a25c6c333cc0e14ec6985d5a48995c918..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00846.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00846") -public class BenchmarkTest00846 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00846" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00846" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00846" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00847.java b/OWASP DATASET CLEANED/BenchmarkTest00847.java deleted file mode 100644 index cbbcd334f9a73fbfb6ca4a736ba99328aa17328b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00847.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00847") -public class BenchmarkTest00847 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00847" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00847" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00847" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00848.java b/OWASP DATASET CLEANED/BenchmarkTest00848.java deleted file mode 100644 index 2f7827d649345cf26f23b479e977c8e106814770..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00848.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00848") -public class BenchmarkTest00848 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00848" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00848" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00848" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = param; - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00849.java b/OWASP DATASET CLEANED/BenchmarkTest00849.java deleted file mode 100644 index f30a871195ff84a94cdff511d64851435ca83d0e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00849.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00849") -public class BenchmarkTest00849 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00849" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00849" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00849" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00850.java b/OWASP DATASET CLEANED/BenchmarkTest00850.java deleted file mode 100644 index 2620b83b739f53bc9bd41d5fa1767433fd94b93a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00850.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00850") -public class BenchmarkTest00850 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00850" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00850" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00850" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00851.java b/OWASP DATASET CLEANED/BenchmarkTest00851.java deleted file mode 100644 index ba5bfe682c0b1547e6ebf4137ab5d64dbd2551f5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00851.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00851") -public class BenchmarkTest00851 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00851" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00851" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00851" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00852.java b/OWASP DATASET CLEANED/BenchmarkTest00852.java deleted file mode 100644 index aca8d6a2ce9a948d5fffc8292147203fca3ee7ee..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00852.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest00852") -public class BenchmarkTest00852 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest00852" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest00852" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest00852" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = "safe!"; - java.util.HashMap map47458 = new java.util.HashMap(); - map47458.put("keyA-47458", "a_Value"); // put some stuff in the collection - map47458.put("keyB-47458", param); // put it in a collection - map47458.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map47458.get("keyB-47458"); // get it back out - bar = (String) map47458.get("keyA-47458"); // get safe value back out - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00853.java b/OWASP DATASET CLEANED/BenchmarkTest00853.java deleted file mode 100644 index d766448df069107b1f5ba759751c4d0b987e8546..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00853.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00853") -public class BenchmarkTest00853 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00853"); - - StringBuilder sbxyz83803 = new StringBuilder(param); - String bar = sbxyz83803.append("_SafeStuff").toString(); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00854.java b/OWASP DATASET CLEANED/BenchmarkTest00854.java deleted file mode 100644 index 78d19843f642810138b045c3c66557a8067bd28e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00854.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00854") -public class BenchmarkTest00854 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00854"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00855.java b/OWASP DATASET CLEANED/BenchmarkTest00855.java deleted file mode 100644 index da6dafc517eca45778eb401b5bc8babdf40a413a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00855.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00855") -public class BenchmarkTest00855 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00855"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00856.java b/OWASP DATASET CLEANED/BenchmarkTest00856.java deleted file mode 100644 index ec0f4145e1d38ccd036a0df881e57b87c99ebf28..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00856.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00856") -public class BenchmarkTest00856 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00856"); - - // Chain a bunch of propagators in sequence - String a98944 = param; // assign - StringBuilder b98944 = new StringBuilder(a98944); // stick in stringbuilder - b98944.append(" SafeStuff"); // append some safe content - b98944.replace( - b98944.length() - "Chars".length(), - b98944.length(), - "Chars"); // replace some of the end content - java.util.HashMap map98944 = new java.util.HashMap(); - map98944.put("key98944", b98944.toString()); // put in a collection - String c98944 = (String) map98944.get("key98944"); // get it back out - String d98944 = c98944.substring(0, c98944.length() - 1); // extract most of it - String e98944 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d98944.getBytes()))); // B64 encode and decode it - String f98944 = e98944.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f98944); // reflection - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00857.java b/OWASP DATASET CLEANED/BenchmarkTest00857.java deleted file mode 100644 index f2d77cde5f97659cb1bac9a96882ba52ed0b7048..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00857.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00857") -public class BenchmarkTest00857 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00857"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00858.java b/OWASP DATASET CLEANED/BenchmarkTest00858.java deleted file mode 100644 index 11ccf506e7bb5690ac16dfc169a6bd87dd3667c6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00858.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00858") -public class BenchmarkTest00858 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00858"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00859.java b/OWASP DATASET CLEANED/BenchmarkTest00859.java deleted file mode 100644 index 355ba46ae92f26247c1ed344f35848f8329f74b4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00859.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00859") -public class BenchmarkTest00859 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00859"); - - String bar = "safe!"; - java.util.HashMap map87594 = new java.util.HashMap(); - map87594.put("keyA-87594", "a-Value"); // put some stuff in the collection - map87594.put("keyB-87594", param); // put it in a collection - map87594.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map87594.get("keyB-87594"); // get it back out - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00860.java b/OWASP DATASET CLEANED/BenchmarkTest00860.java deleted file mode 100644 index 626151d82f295afd9916fcfa7291d43bcc629a24..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00860.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00860") -public class BenchmarkTest00860 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00860"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00861.java b/OWASP DATASET CLEANED/BenchmarkTest00861.java deleted file mode 100644 index 880591d51421ff2ae289a5de0b7b4c3c08130448..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00861.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00861") -public class BenchmarkTest00861 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00861"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00862.java b/OWASP DATASET CLEANED/BenchmarkTest00862.java deleted file mode 100644 index 67bac891440318822696ebd20e52d5c7c70c700e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00862.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00862") -public class BenchmarkTest00862 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00862"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00863.java b/OWASP DATASET CLEANED/BenchmarkTest00863.java deleted file mode 100644 index a2b25d823602d0766d7fbe0e6a5c0ca1e417ab3f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00863.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00863") -public class BenchmarkTest00863 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00863"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00864.java b/OWASP DATASET CLEANED/BenchmarkTest00864.java deleted file mode 100644 index ec41b845c03c1920c9d6c44fe77456596cf13dd2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00864.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00864") -public class BenchmarkTest00864 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00864"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00865.java b/OWASP DATASET CLEANED/BenchmarkTest00865.java deleted file mode 100644 index 81a856851118db502c811c26cf73c9d4daa49638..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00865.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-00/BenchmarkTest00865") -public class BenchmarkTest00865 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00865"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00866.java b/OWASP DATASET CLEANED/BenchmarkTest00866.java deleted file mode 100644 index e2584f98867379f0a8e1c9f7519917eaf84206d7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00866.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00866") -public class BenchmarkTest00866 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00866"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00867.java b/OWASP DATASET CLEANED/BenchmarkTest00867.java deleted file mode 100644 index ac280a242bf5458fdc3ac624ffef83209e4800bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00867.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00867") -public class BenchmarkTest00867 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00867"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00868.java b/OWASP DATASET CLEANED/BenchmarkTest00868.java deleted file mode 100644 index f4ca9ed8cce7631f3bb85579e2cafc8be985529c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00868.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00868") -public class BenchmarkTest00868 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00868"); - - // Chain a bunch of propagators in sequence - String a51118 = param; // assign - StringBuilder b51118 = new StringBuilder(a51118); // stick in stringbuilder - b51118.append(" SafeStuff"); // append some safe content - b51118.replace( - b51118.length() - "Chars".length(), - b51118.length(), - "Chars"); // replace some of the end content - java.util.HashMap map51118 = new java.util.HashMap(); - map51118.put("key51118", b51118.toString()); // put in a collection - String c51118 = (String) map51118.get("key51118"); // get it back out - String d51118 = c51118.substring(0, c51118.length() - 1); // extract most of it - String e51118 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d51118.getBytes()))); // B64 encode and decode it - String f51118 = e51118.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f51118); // reflection - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00869.java b/OWASP DATASET CLEANED/BenchmarkTest00869.java deleted file mode 100644 index d835cd39d414f815b74bbaf3ffcbfd62be8462bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00869.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00869") -public class BenchmarkTest00869 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00869"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00870.java b/OWASP DATASET CLEANED/BenchmarkTest00870.java deleted file mode 100644 index 82565d6f37664e3156fd04da4a9023b0217e70bf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00870.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00870") -public class BenchmarkTest00870 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00870"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00871.java b/OWASP DATASET CLEANED/BenchmarkTest00871.java deleted file mode 100644 index 6e435c0560db6bb34ece4f42e361cb6a1f323bb5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00871.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00871") -public class BenchmarkTest00871 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00871"); - - String bar = "safe!"; - java.util.HashMap map42157 = new java.util.HashMap(); - map42157.put("keyA-42157", "a-Value"); // put some stuff in the collection - map42157.put("keyB-42157", param); // put it in a collection - map42157.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map42157.get("keyB-42157"); // get it back out - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00872.java b/OWASP DATASET CLEANED/BenchmarkTest00872.java deleted file mode 100644 index 05a722bb80565b5409e960153cce2029887dbfdc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00872.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00872") -public class BenchmarkTest00872 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00872"); - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00873.java b/OWASP DATASET CLEANED/BenchmarkTest00873.java deleted file mode 100644 index cd78577a433028de58abc1e7dfe532d4c3aedcdf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00873.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00873") -public class BenchmarkTest00873 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00873"); - - String bar = "safe!"; - java.util.HashMap map58847 = new java.util.HashMap(); - map58847.put("keyA-58847", "a_Value"); // put some stuff in the collection - map58847.put("keyB-58847", param); // put it in a collection - map58847.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map58847.get("keyB-58847"); // get it back out - bar = (String) map58847.get("keyA-58847"); // get safe value back out - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00874.java b/OWASP DATASET CLEANED/BenchmarkTest00874.java deleted file mode 100644 index dea3e0f257704caf5069d16a490707ba08227530..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00874.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00874") -public class BenchmarkTest00874 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00874"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00875.java b/OWASP DATASET CLEANED/BenchmarkTest00875.java deleted file mode 100644 index 52534ac267d0d4978dd6b5cc639ac5abff6768be..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00875.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00875") -public class BenchmarkTest00875 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00875"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00876.java b/OWASP DATASET CLEANED/BenchmarkTest00876.java deleted file mode 100644 index 6f5fb85f6bc4b314868f7908d9d7d4c9275c0a1b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00876.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00876") -public class BenchmarkTest00876 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00876"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00877.java b/OWASP DATASET CLEANED/BenchmarkTest00877.java deleted file mode 100644 index 4fd3e2658f596bd0d2dffc65e227be2f4cfa1320..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00877.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00877") -public class BenchmarkTest00877 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00877"); - - // Chain a bunch of propagators in sequence - String a55741 = param; // assign - StringBuilder b55741 = new StringBuilder(a55741); // stick in stringbuilder - b55741.append(" SafeStuff"); // append some safe content - b55741.replace( - b55741.length() - "Chars".length(), - b55741.length(), - "Chars"); // replace some of the end content - java.util.HashMap map55741 = new java.util.HashMap(); - map55741.put("key55741", b55741.toString()); // put in a collection - String c55741 = (String) map55741.get("key55741"); // get it back out - String d55741 = c55741.substring(0, c55741.length() - 1); // extract most of it - String e55741 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d55741.getBytes()))); // B64 encode and decode it - String f55741 = e55741.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f55741); // reflection - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00878.java b/OWASP DATASET CLEANED/BenchmarkTest00878.java deleted file mode 100644 index d81ddc6ea5c9b48b1853137a517152f1c83dbbc0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00878.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00878") -public class BenchmarkTest00878 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00878"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00879.java b/OWASP DATASET CLEANED/BenchmarkTest00879.java deleted file mode 100644 index 0fce6dcbb24a2c350142fd16df2826562f9f6c18..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00879.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00879") -public class BenchmarkTest00879 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00879"); - - String bar = "safe!"; - java.util.HashMap map11407 = new java.util.HashMap(); - map11407.put("keyA-11407", "a_Value"); // put some stuff in the collection - map11407.put("keyB-11407", param); // put it in a collection - map11407.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map11407.get("keyB-11407"); // get it back out - bar = (String) map11407.get("keyA-11407"); // get safe value back out - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00880.java b/OWASP DATASET CLEANED/BenchmarkTest00880.java deleted file mode 100644 index f0078c868556b4140db4db33c41ef2d264b17d76..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00880.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00880") -public class BenchmarkTest00880 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00880"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00881.java b/OWASP DATASET CLEANED/BenchmarkTest00881.java deleted file mode 100644 index b9706b8bc27da9ef0036de7e6bcc9e06fff32e05..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00881.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00881") -public class BenchmarkTest00881 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00881"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00882.java b/OWASP DATASET CLEANED/BenchmarkTest00882.java deleted file mode 100644 index 9cbb27768a6c168e3eaa0b519bf55d550a658ceb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00882.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00882") -public class BenchmarkTest00882 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00882"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00883.java b/OWASP DATASET CLEANED/BenchmarkTest00883.java deleted file mode 100644 index 64e5e3b2923bdb848058b3a91bed657ae3d40cd3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00883.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00883") -public class BenchmarkTest00883 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00883"); - - // Chain a bunch of propagators in sequence - String a69063 = param; // assign - StringBuilder b69063 = new StringBuilder(a69063); // stick in stringbuilder - b69063.append(" SafeStuff"); // append some safe content - b69063.replace( - b69063.length() - "Chars".length(), - b69063.length(), - "Chars"); // replace some of the end content - java.util.HashMap map69063 = new java.util.HashMap(); - map69063.put("key69063", b69063.toString()); // put in a collection - String c69063 = (String) map69063.get("key69063"); // get it back out - String d69063 = c69063.substring(0, c69063.length() - 1); // extract most of it - String e69063 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d69063.getBytes()))); // B64 encode and decode it - String f69063 = e69063.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f69063); // reflection - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00884.java b/OWASP DATASET CLEANED/BenchmarkTest00884.java deleted file mode 100644 index e57555db1821bcc364e75b899d84bade251fadb6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00884.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00884") -public class BenchmarkTest00884 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00884"); - - String bar = "safe!"; - java.util.HashMap map26388 = new java.util.HashMap(); - map26388.put("keyA-26388", "a_Value"); // put some stuff in the collection - map26388.put("keyB-26388", param); // put it in a collection - map26388.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map26388.get("keyB-26388"); // get it back out - bar = (String) map26388.get("keyA-26388"); // get safe value back out - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00885.java b/OWASP DATASET CLEANED/BenchmarkTest00885.java deleted file mode 100644 index 98872719796019b883ac9c362ff24990f43d9007..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00885.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00885") -public class BenchmarkTest00885 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00885"); - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz28240 = new StringBuilder(param); - bar = sbxyz28240.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00886.java b/OWASP DATASET CLEANED/BenchmarkTest00886.java deleted file mode 100644 index 172fa39b8a4002b0385a7543f08e64198ce1d200..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00886.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00886") -public class BenchmarkTest00886 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00886"); - - String bar = "safe!"; - java.util.HashMap map8361 = new java.util.HashMap(); - map8361.put("keyA-8361", "a_Value"); // put some stuff in the collection - map8361.put("keyB-8361", param); // put it in a collection - map8361.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map8361.get("keyB-8361"); // get it back out - bar = (String) map8361.get("keyA-8361"); // get safe value back out - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00887.java b/OWASP DATASET CLEANED/BenchmarkTest00887.java deleted file mode 100644 index 35b1dd2cd91d58175fd1291af27290f17c415b55..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00887.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00887") -public class BenchmarkTest00887 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00887"); - - String bar = "safe!"; - java.util.HashMap map39726 = new java.util.HashMap(); - map39726.put("keyA-39726", "a-Value"); // put some stuff in the collection - map39726.put("keyB-39726", param); // put it in a collection - map39726.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map39726.get("keyB-39726"); // get it back out - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00888.java b/OWASP DATASET CLEANED/BenchmarkTest00888.java deleted file mode 100644 index cba1c0e0abc7902f25094807f2de09e89996cdbf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00888.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00888") -public class BenchmarkTest00888 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00888"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00889.java b/OWASP DATASET CLEANED/BenchmarkTest00889.java deleted file mode 100644 index b026d7d9952fe4f2a866c831d6c11d55bfd8d4a0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00889.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00889") -public class BenchmarkTest00889 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00889"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00890.java b/OWASP DATASET CLEANED/BenchmarkTest00890.java deleted file mode 100644 index 78839311b2bbe7390be5c3efbc5be356d6f2355b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00890.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00890") -public class BenchmarkTest00890 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00890"); - - String bar = "safe!"; - java.util.HashMap map61765 = new java.util.HashMap(); - map61765.put("keyA-61765", "a-Value"); // put some stuff in the collection - map61765.put("keyB-61765", param); // put it in a collection - map61765.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map61765.get("keyB-61765"); // get it back out - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00891.java b/OWASP DATASET CLEANED/BenchmarkTest00891.java deleted file mode 100644 index 00bb190c615c670b44120b54a48637a7e3ff2578..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00891.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00891") -public class BenchmarkTest00891 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00891"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00892.java b/OWASP DATASET CLEANED/BenchmarkTest00892.java deleted file mode 100644 index 7e9a0cf2b38235975b191f7e9f6981fa30f35ed6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00892.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00892") -public class BenchmarkTest00892 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00892"); - - String bar = param; - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00893.java b/OWASP DATASET CLEANED/BenchmarkTest00893.java deleted file mode 100644 index f596efbf369676a7187786c0fb23503ebd76c735..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00893.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00893") -public class BenchmarkTest00893 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00893"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00894.java b/OWASP DATASET CLEANED/BenchmarkTest00894.java deleted file mode 100644 index c91cc82b454b34aaadaa5ba9f3a5914750073fe4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00894.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest00894") -public class BenchmarkTest00894 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00894"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00895.java b/OWASP DATASET CLEANED/BenchmarkTest00895.java deleted file mode 100644 index 167381094f138e07ed9fb709f11ddc7c3bde4f00..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00895.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00895") -public class BenchmarkTest00895 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00895"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00896.java b/OWASP DATASET CLEANED/BenchmarkTest00896.java deleted file mode 100644 index 73725abfd21b28186ea2150ed1b0c812b4b71b1b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00896.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00896") -public class BenchmarkTest00896 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00896"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00897.java b/OWASP DATASET CLEANED/BenchmarkTest00897.java deleted file mode 100644 index 45ab031fabd16f82ca62f45f60ce8d238cea6e75..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00897.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00897") -public class BenchmarkTest00897 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00897"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00898.java b/OWASP DATASET CLEANED/BenchmarkTest00898.java deleted file mode 100644 index f28b515d76e346a8cefdb1d806148c14cf50e15e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00898.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00898") -public class BenchmarkTest00898 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00898"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00899.java b/OWASP DATASET CLEANED/BenchmarkTest00899.java deleted file mode 100644 index d602492d5764e421652def22818c9c27b2ea57b7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00899.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00899") -public class BenchmarkTest00899 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00899"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00900.java b/OWASP DATASET CLEANED/BenchmarkTest00900.java deleted file mode 100644 index 02f56027046a6dc53d205812a47e8c0f21765009..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00900.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00900") -public class BenchmarkTest00900 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00900"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00901.java b/OWASP DATASET CLEANED/BenchmarkTest00901.java deleted file mode 100644 index 05a8a4802e8f3f90bdd20f7ea4b307bf7759ac33..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00901.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00901") -public class BenchmarkTest00901 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00901"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00902.java b/OWASP DATASET CLEANED/BenchmarkTest00902.java deleted file mode 100644 index aef12c148713304dfda9b42a0bd9025ed1b17b67..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00902.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-01/BenchmarkTest00902") -public class BenchmarkTest00902 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00902"); - - String bar = "safe!"; - java.util.HashMap map21609 = new java.util.HashMap(); - map21609.put("keyA-21609", "a-Value"); // put some stuff in the collection - map21609.put("keyB-21609", param); // put it in a collection - map21609.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map21609.get("keyB-21609"); // get it back out - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00903.java b/OWASP DATASET CLEANED/BenchmarkTest00903.java deleted file mode 100644 index 477ab0229da432d2be3a136e25cf28bf50de6808..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00903.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00903") -public class BenchmarkTest00903 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00903"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00904.java b/OWASP DATASET CLEANED/BenchmarkTest00904.java deleted file mode 100644 index de89ec1a2cdd3b27381ffe04d91c60f292587bff..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00904.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00904") -public class BenchmarkTest00904 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00904"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00905.java b/OWASP DATASET CLEANED/BenchmarkTest00905.java deleted file mode 100644 index ef81c7193fd607afb1e5bf0a46aa9c9d2d91a72f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00905.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00905") -public class BenchmarkTest00905 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00905"); - - String bar = param; - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00906.java b/OWASP DATASET CLEANED/BenchmarkTest00906.java deleted file mode 100644 index c1257c933aaab45a0ad7907389e88eaad50d692f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00906.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00906") -public class BenchmarkTest00906 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00906"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00907.java b/OWASP DATASET CLEANED/BenchmarkTest00907.java deleted file mode 100644 index d85a72de93f19a017d147695ccc416ea925ecdd3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00907.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00907") -public class BenchmarkTest00907 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00907"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00908.java b/OWASP DATASET CLEANED/BenchmarkTest00908.java deleted file mode 100644 index 921fd4d308834315c6ed3b8e1e17772904fe2066..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00908.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00908") -public class BenchmarkTest00908 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00908"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00909.java b/OWASP DATASET CLEANED/BenchmarkTest00909.java deleted file mode 100644 index 1e575a2143c9f1c83207971a413c3b1af9153243..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00909.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00909") -public class BenchmarkTest00909 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00909"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00910.java b/OWASP DATASET CLEANED/BenchmarkTest00910.java deleted file mode 100644 index b1e2c965ac361e785826b4c5c47b0b2ba965d2d8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00910.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00910") -public class BenchmarkTest00910 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00910"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00911.java b/OWASP DATASET CLEANED/BenchmarkTest00911.java deleted file mode 100644 index 6971e4e2121f5635060f04818c8192df08cb846e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00911.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00911") -public class BenchmarkTest00911 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00911"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00912.java b/OWASP DATASET CLEANED/BenchmarkTest00912.java deleted file mode 100644 index 7c1b407c05099dacc0d2adcdbd6ef0a6feb653f1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00912.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00912") -public class BenchmarkTest00912 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00912"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00913.java b/OWASP DATASET CLEANED/BenchmarkTest00913.java deleted file mode 100644 index c7ab70495c7e74ace340b7d0832518e12b6653e4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00913.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00913") -public class BenchmarkTest00913 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00913"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00914.java b/OWASP DATASET CLEANED/BenchmarkTest00914.java deleted file mode 100644 index 600c8f462ba6f8f55fbb61a7ef7552447dd4c2b9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00914.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00914") -public class BenchmarkTest00914 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00914"); - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00915.java b/OWASP DATASET CLEANED/BenchmarkTest00915.java deleted file mode 100644 index 3eb804abcf1c861140369e60702669a3158a8a38..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00915.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00915") -public class BenchmarkTest00915 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00915"); - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00916.java b/OWASP DATASET CLEANED/BenchmarkTest00916.java deleted file mode 100644 index 11a617957818b2e6b3052ec0a11bcc726ff99032..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00916.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00916") -public class BenchmarkTest00916 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00916"); - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00917.java b/OWASP DATASET CLEANED/BenchmarkTest00917.java deleted file mode 100644 index 6eff6423d5ddc5c1ebfac285f05536517ffe0457..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00917.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00917") -public class BenchmarkTest00917 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00917"); - - String bar = "safe!"; - java.util.HashMap map5880 = new java.util.HashMap(); - map5880.put("keyA-5880", "a_Value"); // put some stuff in the collection - map5880.put("keyB-5880", param); // put it in a collection - map5880.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map5880.get("keyB-5880"); // get it back out - bar = (String) map5880.get("keyA-5880"); // get safe value back out - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00918.java b/OWASP DATASET CLEANED/BenchmarkTest00918.java deleted file mode 100644 index 014967b102054c91ed7f62eacc4b20d94828a650..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00918.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00918") -public class BenchmarkTest00918 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00918"); - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00919.java b/OWASP DATASET CLEANED/BenchmarkTest00919.java deleted file mode 100644 index f4ed897851557e89ed99eb0440617b23511c45c0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00919.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00919") -public class BenchmarkTest00919 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00919"); - - String bar = param; - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00920.java b/OWASP DATASET CLEANED/BenchmarkTest00920.java deleted file mode 100644 index e2ac6308345a3ec928d667fb5398fed4791f204d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00920.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00920") -public class BenchmarkTest00920 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00920"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00921.java b/OWASP DATASET CLEANED/BenchmarkTest00921.java deleted file mode 100644 index 40636751c9a80cba88d6c0472f08d80773c043b4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00921.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00921") -public class BenchmarkTest00921 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00921"); - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00922.java b/OWASP DATASET CLEANED/BenchmarkTest00922.java deleted file mode 100644 index 0544c6107b5696a99eb5293f4a3111e213e77060..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00922.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00922") -public class BenchmarkTest00922 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00922"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00923.java b/OWASP DATASET CLEANED/BenchmarkTest00923.java deleted file mode 100644 index e181d9882364cf11e2cf0d78bed8424775e3356c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00923.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00923") -public class BenchmarkTest00923 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00923"); - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00924.java b/OWASP DATASET CLEANED/BenchmarkTest00924.java deleted file mode 100644 index d0664cb51eabeab36504705ea0959dc580f3350f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00924.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00924") -public class BenchmarkTest00924 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00924"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00925.java b/OWASP DATASET CLEANED/BenchmarkTest00925.java deleted file mode 100644 index 988638bb987fdca00a764f81ff2d7cbe138c1711..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00925.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00925") -public class BenchmarkTest00925 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00925"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00926.java b/OWASP DATASET CLEANED/BenchmarkTest00926.java deleted file mode 100644 index 30e8fd41cbe38ff5999220aca58e86fd1c5a7845..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00926.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00926") -public class BenchmarkTest00926 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00926"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00927.java b/OWASP DATASET CLEANED/BenchmarkTest00927.java deleted file mode 100644 index 27b2f2c443c550e88b1aff136e8c94c59f3cf636..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00927.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00927") -public class BenchmarkTest00927 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00927"); - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00928.java b/OWASP DATASET CLEANED/BenchmarkTest00928.java deleted file mode 100644 index 248fc78c23911999e1cd1587d85220bf7c254eaa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00928.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00928") -public class BenchmarkTest00928 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00928"); - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00929.java b/OWASP DATASET CLEANED/BenchmarkTest00929.java deleted file mode 100644 index 5781c5c28f7559be5b34f38890bfa7ed22f68a1a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00929.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00929") -public class BenchmarkTest00929 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00929"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00930.java b/OWASP DATASET CLEANED/BenchmarkTest00930.java deleted file mode 100644 index f655409ae637b9cc805d7595c9380228d6b137d7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00930.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00930") -public class BenchmarkTest00930 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00930"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00931.java b/OWASP DATASET CLEANED/BenchmarkTest00931.java deleted file mode 100644 index f90e1d9ad2ae83f6b789f3bc9f6889f2b0f850d2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00931.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00931") -public class BenchmarkTest00931 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00931"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00932.java b/OWASP DATASET CLEANED/BenchmarkTest00932.java deleted file mode 100644 index 3f81ff42fe6bd85a60cb1ac174f504c57fe94827..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00932.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00932") -public class BenchmarkTest00932 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00932"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00933.java b/OWASP DATASET CLEANED/BenchmarkTest00933.java deleted file mode 100644 index 40757c3adf7e7389ab8cae82bb0261f61ec46a9c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00933.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00933") -public class BenchmarkTest00933 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00933"); - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00934.java b/OWASP DATASET CLEANED/BenchmarkTest00934.java deleted file mode 100644 index cd8ea35bc250414ce05a64cabeb1750fd2228eb2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00934.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00934") -public class BenchmarkTest00934 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00934"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00935.java b/OWASP DATASET CLEANED/BenchmarkTest00935.java deleted file mode 100644 index 9b877a80f74af1e689a1ea0ecdd452d4b1061369..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00935.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-01/BenchmarkTest00935") -public class BenchmarkTest00935 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00935"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00936.java b/OWASP DATASET CLEANED/BenchmarkTest00936.java deleted file mode 100644 index 5ceb287b4a4355448f1de787eb89f156ae03d9d6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00936.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest00936") -public class BenchmarkTest00936 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00936"); - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00937.java b/OWASP DATASET CLEANED/BenchmarkTest00937.java deleted file mode 100644 index 0c42e5289985ea0f4b71884680250a947e65c294..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00937.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest00937") -public class BenchmarkTest00937 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00937"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00938.java b/OWASP DATASET CLEANED/BenchmarkTest00938.java deleted file mode 100644 index eb94dd760f83397e26bd45604bee71edc4365e4b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00938.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest00938") -public class BenchmarkTest00938 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00938"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00939.java b/OWASP DATASET CLEANED/BenchmarkTest00939.java deleted file mode 100644 index 5e50ed325a196a021f1d1955044be20ee1085495..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00939.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest00939") -public class BenchmarkTest00939 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00939"); - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00940.java b/OWASP DATASET CLEANED/BenchmarkTest00940.java deleted file mode 100644 index 8c6ee2a8abe3d905b366810faebcc056cf127943..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00940.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest00940") -public class BenchmarkTest00940 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00940"); - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00941.java b/OWASP DATASET CLEANED/BenchmarkTest00941.java deleted file mode 100644 index d28cf455737955a2c06208eda69736b182c24f52..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00941.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest00941") -public class BenchmarkTest00941 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest00941"); - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest00942.java b/OWASP DATASET CLEANED/BenchmarkTest00942.java deleted file mode 100644 index edabdd97663a8c647ae921787edc21cb3e046c4d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00942.java +++ /dev/null @@ -1,186 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00942") -public class BenchmarkTest00942 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00942", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-01/BenchmarkTest00942.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00942")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00943.java b/OWASP DATASET CLEANED/BenchmarkTest00943.java deleted file mode 100644 index 7ea33e0c3f547212c3404b7c585ff511279ce6e9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00943.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00943") -public class BenchmarkTest00943 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00943", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-01/BenchmarkTest00943.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00943")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00944.java b/OWASP DATASET CLEANED/BenchmarkTest00944.java deleted file mode 100644 index a96c19cb02f272c1a989583ba00791f75481beb1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00944.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00944") -public class BenchmarkTest00944 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00944", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-01/BenchmarkTest00944.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00944")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00945.java b/OWASP DATASET CLEANED/BenchmarkTest00945.java deleted file mode 100644 index 69b502d954da99a811d92c92ef914186261cf9ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00945.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00945") -public class BenchmarkTest00945 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00945", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-01/BenchmarkTest00945.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00945")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00946.java b/OWASP DATASET CLEANED/BenchmarkTest00946.java deleted file mode 100644 index 8a48761126457ef498104636279135de59518bba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00946.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest00946") -public class BenchmarkTest00946 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00946", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-01/BenchmarkTest00946.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00946")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00947.java b/OWASP DATASET CLEANED/BenchmarkTest00947.java deleted file mode 100644 index abe6252c574d7bdc1ceedd3420a26b061469e52c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00947.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00947") -public class BenchmarkTest00947 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00947", "Ms+Bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/ldapi-00/BenchmarkTest00947.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00947")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00948.java b/OWASP DATASET CLEANED/BenchmarkTest00948.java deleted file mode 100644 index be08aa50e1dc6cf8458df2d37a6f7bb7e776288c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00948.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00948") -public class BenchmarkTest00948 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00948", "Ms+Bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/ldapi-00/BenchmarkTest00948.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00948")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map72608 = new java.util.HashMap(); - map72608.put("keyA-72608", "a_Value"); // put some stuff in the collection - map72608.put("keyB-72608", param); // put it in a collection - map72608.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map72608.get("keyB-72608"); // get it back out - bar = (String) map72608.get("keyA-72608"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00949.java b/OWASP DATASET CLEANED/BenchmarkTest00949.java deleted file mode 100644 index 0e393f0819ddf7f33cf6308952135b4b97d65168..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00949.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00949") -public class BenchmarkTest00949 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00949", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-01/BenchmarkTest00949.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00949")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00950.java b/OWASP DATASET CLEANED/BenchmarkTest00950.java deleted file mode 100644 index 21b522e8369992e5aaf76601fe7d8681679856e1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00950.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00950") -public class BenchmarkTest00950 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00950", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-01/BenchmarkTest00950.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00950")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00951.java b/OWASP DATASET CLEANED/BenchmarkTest00951.java deleted file mode 100644 index 07bb305764a79304ab88993b89c6296b595754e8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00951.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00951") -public class BenchmarkTest00951 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00951", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-01/BenchmarkTest00951.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00951")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00952.java b/OWASP DATASET CLEANED/BenchmarkTest00952.java deleted file mode 100644 index 194f107ef2723420f64b8386e09ad2b26bc37a47..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00952.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00952") -public class BenchmarkTest00952 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00952", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-01/BenchmarkTest00952.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00952")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00953.java b/OWASP DATASET CLEANED/BenchmarkTest00953.java deleted file mode 100644 index 24f827ae47a585f5a8c66a9818ef04d0a612340e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00953.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00953") -public class BenchmarkTest00953 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00953", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-01/BenchmarkTest00953.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00953")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00954.java b/OWASP DATASET CLEANED/BenchmarkTest00954.java deleted file mode 100644 index 68d74099401ec7e2fc594333b796f8cb3142b05a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00954.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00954") -public class BenchmarkTest00954 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00954", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-01/BenchmarkTest00954.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00954")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map9749 = new java.util.HashMap(); - map9749.put("keyA-9749", "a_Value"); // put some stuff in the collection - map9749.put("keyB-9749", param); // put it in a collection - map9749.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map9749.get("keyB-9749"); // get it back out - bar = (String) map9749.get("keyA-9749"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00955.java b/OWASP DATASET CLEANED/BenchmarkTest00955.java deleted file mode 100644 index c84ef7cb2aadb390034510081d85717c582ebf72..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00955.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00955") -public class BenchmarkTest00955 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00955", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-01/BenchmarkTest00955.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00955")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00956.java b/OWASP DATASET CLEANED/BenchmarkTest00956.java deleted file mode 100644 index 875d0ccbb3d9061476ca20593e40d65e45b04493..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00956.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00956") -public class BenchmarkTest00956 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00956", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-01/BenchmarkTest00956.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00956")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00957.java b/OWASP DATASET CLEANED/BenchmarkTest00957.java deleted file mode 100644 index 55f1406de6bd25df91e5ebd12f7b748066b62ab8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00957.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00957") -public class BenchmarkTest00957 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00957", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-01/BenchmarkTest00957.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00957")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00958.java b/OWASP DATASET CLEANED/BenchmarkTest00958.java deleted file mode 100644 index d520eaa57c3e764c51832e353f6c65bd3e7b54cb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00958.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest00958") -public class BenchmarkTest00958 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00958", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-01/BenchmarkTest00958.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00958")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map37053 = new java.util.HashMap(); - map37053.put("keyA-37053", "a_Value"); // put some stuff in the collection - map37053.put("keyB-37053", param); // put it in a collection - map37053.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map37053.get("keyB-37053"); // get it back out - bar = (String) map37053.get("keyA-37053"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00959.java b/OWASP DATASET CLEANED/BenchmarkTest00959.java deleted file mode 100644 index e2fe46e453b79ce9f496b3026e862afe669b07bc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00959.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest00959") -public class BenchmarkTest00959 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00959", "Ms+Bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/ldapi-00/BenchmarkTest00959.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00959")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00960.java b/OWASP DATASET CLEANED/BenchmarkTest00960.java deleted file mode 100644 index cf958884b598861b5e734ed533cba4c4664beab0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00960.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00960") -public class BenchmarkTest00960 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00960", "anything"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00960.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00960")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map19964 = new java.util.HashMap(); - map19964.put("keyA-19964", "a_Value"); // put some stuff in the collection - map19964.put("keyB-19964", param); // put it in a collection - map19964.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map19964.get("keyB-19964"); // get it back out - bar = (String) map19964.get("keyA-19964"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00961.java b/OWASP DATASET CLEANED/BenchmarkTest00961.java deleted file mode 100644 index 29ba4140377e9653648a98cf704fc0e9cf26e65a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00961.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00961") -public class BenchmarkTest00961 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00961", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-01/BenchmarkTest00961.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00961")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map47722 = new java.util.HashMap(); - map47722.put("keyA-47722", "a_Value"); // put some stuff in the collection - map47722.put("keyB-47722", param); // put it in a collection - map47722.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map47722.get("keyB-47722"); // get it back out - bar = (String) map47722.get("keyA-47722"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00962.java b/OWASP DATASET CLEANED/BenchmarkTest00962.java deleted file mode 100644 index ca328b4764af5bcf23c5e527e067394063053e4b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00962.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00962") -public class BenchmarkTest00962 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00962", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-01/BenchmarkTest00962.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00962")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00963.java b/OWASP DATASET CLEANED/BenchmarkTest00963.java deleted file mode 100644 index 92d5597e268a21a6ebcbcb0ce7c5af9d7020491f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00963.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00963") -public class BenchmarkTest00963 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00963", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-01/BenchmarkTest00963.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00963")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00964.java b/OWASP DATASET CLEANED/BenchmarkTest00964.java deleted file mode 100644 index 921bceab52e56794e0282c548aecdfb27ac3885b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00964.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00964") -public class BenchmarkTest00964 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00964", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-01/BenchmarkTest00964.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00964")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00965.java b/OWASP DATASET CLEANED/BenchmarkTest00965.java deleted file mode 100644 index cb36981d2f77b0aa78c35a4e3ddfb8beae39c0c9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00965.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00965") -public class BenchmarkTest00965 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00965", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-01/BenchmarkTest00965.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00965")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map47189 = new java.util.HashMap(); - map47189.put("keyA-47189", "a-Value"); // put some stuff in the collection - map47189.put("keyB-47189", param); // put it in a collection - map47189.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map47189.get("keyB-47189"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00966.java b/OWASP DATASET CLEANED/BenchmarkTest00966.java deleted file mode 100644 index f384468ec05c4be4d94218f3cb310d4137f8bc47..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00966.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00966") -public class BenchmarkTest00966 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00966", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-01/BenchmarkTest00966.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00966")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00967.java b/OWASP DATASET CLEANED/BenchmarkTest00967.java deleted file mode 100644 index 7293356639d3025ddbb048c6aa0f45ee811d340a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00967.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest00967") -public class BenchmarkTest00967 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00967", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-01/BenchmarkTest00967.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00967")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00968.java b/OWASP DATASET CLEANED/BenchmarkTest00968.java deleted file mode 100644 index 8f08cb3fcdf92f45b805df86c736a6ce471a05e9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00968.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00968") -public class BenchmarkTest00968 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00968", "ECHOOO"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-01/BenchmarkTest00968.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00968")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00969.java b/OWASP DATASET CLEANED/BenchmarkTest00969.java deleted file mode 100644 index 7f22d1c2d380649d2196c7892e15cfaf16521355..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00969.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00969") -public class BenchmarkTest00969 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00969", "ECHOOO"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-01/BenchmarkTest00969.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00969")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a10263 = param; // assign - StringBuilder b10263 = new StringBuilder(a10263); // stick in stringbuilder - b10263.append(" SafeStuff"); // append some safe content - b10263.replace( - b10263.length() - "Chars".length(), - b10263.length(), - "Chars"); // replace some of the end content - java.util.HashMap map10263 = new java.util.HashMap(); - map10263.put("key10263", b10263.toString()); // put in a collection - String c10263 = (String) map10263.get("key10263"); // get it back out - String d10263 = c10263.substring(0, c10263.length() - 1); // extract most of it - String e10263 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d10263.getBytes()))); // B64 encode and decode it - String f10263 = e10263.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g10263 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g10263); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00970.java b/OWASP DATASET CLEANED/BenchmarkTest00970.java deleted file mode 100644 index 85aa5e1837450a665e8514155ade9e452f5f9c90..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00970.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00970") -public class BenchmarkTest00970 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00970", "ECHOOO"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-01/BenchmarkTest00970.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00970")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00971.java b/OWASP DATASET CLEANED/BenchmarkTest00971.java deleted file mode 100644 index e150eb0ab2b4e0b2626e65d13956a1f331599085..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00971.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00971") -public class BenchmarkTest00971 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00971", "does_not_matter"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00971.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00971")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00972.java b/OWASP DATASET CLEANED/BenchmarkTest00972.java deleted file mode 100644 index cd955a1bee356a0a46782c37f695b5e0092d97a2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00972.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00972") -public class BenchmarkTest00972 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00972", "does_not_matter"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00972.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00972")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map73877 = new java.util.HashMap(); - map73877.put("keyA-73877", "a_Value"); // put some stuff in the collection - map73877.put("keyB-73877", param); // put it in a collection - map73877.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map73877.get("keyB-73877"); // get it back out - bar = (String) map73877.get("keyA-73877"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00973.java b/OWASP DATASET CLEANED/BenchmarkTest00973.java deleted file mode 100644 index 792c74c173e539cc72c40c67f40899dc8a4087fe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00973.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00973") -public class BenchmarkTest00973 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00973", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00973.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00973")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00974.java b/OWASP DATASET CLEANED/BenchmarkTest00974.java deleted file mode 100644 index 6ae56d14bb8fedfcc84def6e2066dc43e3cdf34b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00974.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00974") -public class BenchmarkTest00974 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00974", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00974.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00974")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00975.java b/OWASP DATASET CLEANED/BenchmarkTest00975.java deleted file mode 100644 index 25275cf1ba0d86ddc3375b95b2865683ecaa5b55..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00975.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00975") -public class BenchmarkTest00975 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00975", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00975.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00975")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00976.java b/OWASP DATASET CLEANED/BenchmarkTest00976.java deleted file mode 100644 index e71cdac3e63223f5832f0b7ab5c4d34b0582b9a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00976.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00976") -public class BenchmarkTest00976 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00976", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00976.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00976")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00977.java b/OWASP DATASET CLEANED/BenchmarkTest00977.java deleted file mode 100644 index 6cfc9bd8cd92731061c3eb0b0bf2c5992f55de72..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00977.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest00977") -public class BenchmarkTest00977 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00977", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/securecookie-00/BenchmarkTest00977.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00977")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00978.java b/OWASP DATASET CLEANED/BenchmarkTest00978.java deleted file mode 100644 index e0c51eb64ca973a4ef63902f7b662d054caeb554..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00978.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00978") -public class BenchmarkTest00978 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00978", "localhost"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-01/BenchmarkTest00978.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00978")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a60830 = param; // assign - StringBuilder b60830 = new StringBuilder(a60830); // stick in stringbuilder - b60830.append(" SafeStuff"); // append some safe content - b60830.replace( - b60830.length() - "Chars".length(), - b60830.length(), - "Chars"); // replace some of the end content - java.util.HashMap map60830 = new java.util.HashMap(); - map60830.put("key60830", b60830.toString()); // put in a collection - String c60830 = (String) map60830.get("key60830"); // get it back out - String d60830 = c60830.substring(0, c60830.length() - 1); // extract most of it - String e60830 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d60830.getBytes()))); // B64 encode and decode it - String f60830 = e60830.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g60830 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g60830); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00979.java b/OWASP DATASET CLEANED/BenchmarkTest00979.java deleted file mode 100644 index ebf6fdd539fd2d59be4e44613dbb76d427e8f64f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00979.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00979") -public class BenchmarkTest00979 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00979", "."); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-01/BenchmarkTest00979.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00979")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00980.java b/OWASP DATASET CLEANED/BenchmarkTest00980.java deleted file mode 100644 index 89212fae69a238ecb99f9388c7855227044a2d5a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00980.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00980") -public class BenchmarkTest00980 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00980", "FOO%3Decho+Injection"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-01/BenchmarkTest00980.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00980")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00981.java b/OWASP DATASET CLEANED/BenchmarkTest00981.java deleted file mode 100644 index c5d2ae0c1629ef2aeb1f26a38ce8b07fe3e104f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00981.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00981") -public class BenchmarkTest00981 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00981", "."); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-01/BenchmarkTest00981.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00981")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00982.java b/OWASP DATASET CLEANED/BenchmarkTest00982.java deleted file mode 100644 index a7fdbec6718f78a9e51f2ccc0a8a00e36511aaa1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00982.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00982") -public class BenchmarkTest00982 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00982", "FOO%3Decho+Injection"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-01/BenchmarkTest00982.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00982")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map20875 = new java.util.HashMap(); - map20875.put("keyA-20875", "a_Value"); // put some stuff in the collection - map20875.put("keyB-20875", param); // put it in a collection - map20875.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map20875.get("keyB-20875"); // get it back out - bar = (String) map20875.get("keyA-20875"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00983.java b/OWASP DATASET CLEANED/BenchmarkTest00983.java deleted file mode 100644 index 039fd35eab8bf99e69679ebd58792b779a49e57a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00983.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest00983") -public class BenchmarkTest00983 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00983", "FOO%3Decho+Injection"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-01/BenchmarkTest00983.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00983")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00984.java b/OWASP DATASET CLEANED/BenchmarkTest00984.java deleted file mode 100644 index 80770adc19a49d2a8d5fbb0d301c9fccde1f7a99..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00984.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00984") -public class BenchmarkTest00984 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00984", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00984.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00984")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a50427 = param; // assign - StringBuilder b50427 = new StringBuilder(a50427); // stick in stringbuilder - b50427.append(" SafeStuff"); // append some safe content - b50427.replace( - b50427.length() - "Chars".length(), - b50427.length(), - "Chars"); // replace some of the end content - java.util.HashMap map50427 = new java.util.HashMap(); - map50427.put("key50427", b50427.toString()); // put in a collection - String c50427 = (String) map50427.get("key50427"); // get it back out - String d50427 = c50427.substring(0, c50427.length() - 1); // extract most of it - String e50427 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d50427.getBytes()))); // B64 encode and decode it - String f50427 = e50427.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g50427 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g50427); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00985.java b/OWASP DATASET CLEANED/BenchmarkTest00985.java deleted file mode 100644 index f1afe3457af3f23fc592446a5e2c9de6b2c1ab60..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00985.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00985") -public class BenchmarkTest00985 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00985", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00985.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00985")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz77085 = new StringBuilder(param); - bar = - sbxyz77085 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00986.java b/OWASP DATASET CLEANED/BenchmarkTest00986.java deleted file mode 100644 index 35e7aec7effd7d6f66948f61ebbfc5f1a6b21836..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00986.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00986") -public class BenchmarkTest00986 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00986", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00986.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00986")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00987.java b/OWASP DATASET CLEANED/BenchmarkTest00987.java deleted file mode 100644 index 5a112527cdcb97ac22348ba09ea1b98d68cfa666..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00987.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00987") -public class BenchmarkTest00987 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00987", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00987.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00987")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00988.java b/OWASP DATASET CLEANED/BenchmarkTest00988.java deleted file mode 100644 index a1af647dd035d79e61d1291f6797eb2cd193fbbb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00988.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00988") -public class BenchmarkTest00988 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00988", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00988.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00988")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00989.java b/OWASP DATASET CLEANED/BenchmarkTest00989.java deleted file mode 100644 index a1f592860ee3f4c544496639a691d5711f55fd2f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00989.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00989") -public class BenchmarkTest00989 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00989", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00989.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00989")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a36538 = param; // assign - StringBuilder b36538 = new StringBuilder(a36538); // stick in stringbuilder - b36538.append(" SafeStuff"); // append some safe content - b36538.replace( - b36538.length() - "Chars".length(), - b36538.length(), - "Chars"); // replace some of the end content - java.util.HashMap map36538 = new java.util.HashMap(); - map36538.put("key36538", b36538.toString()); // put in a collection - String c36538 = (String) map36538.get("key36538"); // get it back out - String d36538 = c36538.substring(0, c36538.length() - 1); // extract most of it - String e36538 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d36538.getBytes()))); // B64 encode and decode it - String f36538 = e36538.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f36538); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00990.java b/OWASP DATASET CLEANED/BenchmarkTest00990.java deleted file mode 100644 index ada688ffb3c3fe8056b857a02245af2afa235bc7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00990.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest00990") -public class BenchmarkTest00990 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00990", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-02/BenchmarkTest00990.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00990")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00991.java b/OWASP DATASET CLEANED/BenchmarkTest00991.java deleted file mode 100644 index 1594460d8e8beceb190117e5740caeea22bb3a6a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00991.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00991") -public class BenchmarkTest00991 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00991", "color"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-00/BenchmarkTest00991.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00991")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00992.java b/OWASP DATASET CLEANED/BenchmarkTest00992.java deleted file mode 100644 index 15fa167ba5af58b06a59cd5dc75201574701c0d2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00992.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00992") -public class BenchmarkTest00992 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00992", "color"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-00/BenchmarkTest00992.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00992")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00993.java b/OWASP DATASET CLEANED/BenchmarkTest00993.java deleted file mode 100644 index b4fd61317b235b25af785ae0cb89e5900cad4492..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00993.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00993") -public class BenchmarkTest00993 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00993", "my_user_id"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-00/BenchmarkTest00993.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00993")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00994.java b/OWASP DATASET CLEANED/BenchmarkTest00994.java deleted file mode 100644 index 59ae63227649f70fb752985004642929c5e9bfe6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00994.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00994") -public class BenchmarkTest00994 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00994", "my_user_id"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-00/BenchmarkTest00994.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00994")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00995.java b/OWASP DATASET CLEANED/BenchmarkTest00995.java deleted file mode 100644 index c25441aff9bdda28751fb7f3f57fb536a7efdf55..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00995.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest00995") -public class BenchmarkTest00995 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest00995", "color"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-00/BenchmarkTest00995.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00995")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00996.java b/OWASP DATASET CLEANED/BenchmarkTest00996.java deleted file mode 100644 index 2b9e41e14efc5e10f1016e1c11f6acb3908e4386..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00996.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest00996") -public class BenchmarkTest00996 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie( - "BenchmarkTest00996", "verifyUserPassword%28%27foo%27%2C%27bar%27%29"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest00996.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00996")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00997.java b/OWASP DATASET CLEANED/BenchmarkTest00997.java deleted file mode 100644 index 6c7b31f6e1ee8cae80441702a2f5d04a5ac6b78e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00997.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest00997") -public class BenchmarkTest00997 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie( - "BenchmarkTest00997", "verifyUserPassword%28%27foo%27%2C%27bar%27%29"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest00997.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00997")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00998.java b/OWASP DATASET CLEANED/BenchmarkTest00998.java deleted file mode 100644 index 73c26ad08341eaabc359dbef90d26b2f9d44ccfb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00998.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest00998") -public class BenchmarkTest00998 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie( - "BenchmarkTest00998", "verifyUserPassword%28%27foo%27%2C%27bar%27%29"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest00998.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00998")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest00999.java b/OWASP DATASET CLEANED/BenchmarkTest00999.java deleted file mode 100644 index 94a7b8b61e89a758981d44f51d193f1538e95b49..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest00999.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest00999") -public class BenchmarkTest00999 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie( - "BenchmarkTest00999", "verifyUserPassword%28%27foo%27%2C%27bar%27%29"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest00999.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest00999")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01000.java b/OWASP DATASET CLEANED/BenchmarkTest01000.java deleted file mode 100644 index d964166002f86fb6911f86641c353d2d01bcb731..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01000.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01000") -public class BenchmarkTest01000 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie( - "BenchmarkTest01000", "verifyUserPassword%28%27foo%27%2C%27bar%27%29"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01000.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01000")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01001.java b/OWASP DATASET CLEANED/BenchmarkTest01001.java deleted file mode 100644 index b3024e606ad782a70669075132a2b19f98f6a4d2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01001.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01001") -public class BenchmarkTest01001 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01001", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01001.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01001")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01002.java b/OWASP DATASET CLEANED/BenchmarkTest01002.java deleted file mode 100644 index eee25d4fec68bb0d4ef30e1646eb677ee8cc3631..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01002.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01002") -public class BenchmarkTest01002 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01002", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01002.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01002")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new int[] {1, 2}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01003.java b/OWASP DATASET CLEANED/BenchmarkTest01003.java deleted file mode 100644 index 79e20c2eb57ba6cefc689ce187737e695d107631..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01003.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01003") -public class BenchmarkTest01003 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01003", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01003.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01003")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01004.java b/OWASP DATASET CLEANED/BenchmarkTest01004.java deleted file mode 100644 index 771de318a942bf6b7e07aabd2c5757a2379d1d84..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01004.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01004") -public class BenchmarkTest01004 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01004", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01004.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01004")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01005.java b/OWASP DATASET CLEANED/BenchmarkTest01005.java deleted file mode 100644 index 0889432362dd7e2f9d31a862678dfd5ff81b154d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01005.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01005") -public class BenchmarkTest01005 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01005", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01005.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01005")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01006.java b/OWASP DATASET CLEANED/BenchmarkTest01006.java deleted file mode 100644 index cd63247e71b722278639a9a53bfe394bd85cf8f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01006.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01006") -public class BenchmarkTest01006 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01006", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01006.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01006")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map36088 = new java.util.HashMap(); - map36088.put("keyA-36088", "a-Value"); // put some stuff in the collection - map36088.put("keyB-36088", param); // put it in a collection - map36088.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map36088.get("keyB-36088"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01007.java b/OWASP DATASET CLEANED/BenchmarkTest01007.java deleted file mode 100644 index 7174b1aa4135edc1b7b01c07f5f06c6fe7e1e421..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01007.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01007") -public class BenchmarkTest01007 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01007", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01007.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01007")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01008.java b/OWASP DATASET CLEANED/BenchmarkTest01008.java deleted file mode 100644 index c5ab84f61e261c5b15b98737b2fedaaefe484a01..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01008.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01008") -public class BenchmarkTest01008 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01008", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01008.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01008")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01009.java b/OWASP DATASET CLEANED/BenchmarkTest01009.java deleted file mode 100644 index c70a6b7bfc4c084a7666eece7e115f572f3ea28d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01009.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01009") -public class BenchmarkTest01009 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01009", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01009.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01009")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01010.java b/OWASP DATASET CLEANED/BenchmarkTest01010.java deleted file mode 100644 index 9e29c5f81e14a166ff8ef4ea6f80ffb501f2e965..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01010.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01010") -public class BenchmarkTest01010 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01010", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01010.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01010")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01011.java b/OWASP DATASET CLEANED/BenchmarkTest01011.java deleted file mode 100644 index 9d4e34dab20906e2c1405b564d788a246e3e2f23..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01011.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01011") -public class BenchmarkTest01011 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01011", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01011.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01011")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01012.java b/OWASP DATASET CLEANED/BenchmarkTest01012.java deleted file mode 100644 index cf46c411d89b8290ae7fc2cdd00ecb69ce034af6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01012.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01012") -public class BenchmarkTest01012 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01012", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-02/BenchmarkTest01012.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01012")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01013.java b/OWASP DATASET CLEANED/BenchmarkTest01013.java deleted file mode 100644 index d768a1066a06bfc1321749e0315481c684e65dc0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01013.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01013") -public class BenchmarkTest01013 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01013", "2222"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/xpathi-00/BenchmarkTest01013.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01013")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01014.java b/OWASP DATASET CLEANED/BenchmarkTest01014.java deleted file mode 100644 index 1ea8bdfd1475bb65f49b278c5f4f531637eacc61..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01014.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01014") -public class BenchmarkTest01014 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01014", "2222"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/xpathi-00/BenchmarkTest01014.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01014")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01015.java b/OWASP DATASET CLEANED/BenchmarkTest01015.java deleted file mode 100644 index 0a224e658056b1ab52b76707aa0678e66b108694..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01015.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01015") -public class BenchmarkTest01015 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01015") != null) { - param = request.getHeader("BenchmarkTest01015"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01016.java b/OWASP DATASET CLEANED/BenchmarkTest01016.java deleted file mode 100644 index 5de89e0a26310f0dbe63d5d65972b0fb29c46bc1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01016.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01016") -public class BenchmarkTest01016 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01016") != null) { - param = request.getHeader("BenchmarkTest01016"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map24774 = new java.util.HashMap(); - map24774.put("keyA-24774", "a_Value"); // put some stuff in the collection - map24774.put("keyB-24774", param); // put it in a collection - map24774.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map24774.get("keyB-24774"); // get it back out - bar = (String) map24774.get("keyA-24774"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01017.java b/OWASP DATASET CLEANED/BenchmarkTest01017.java deleted file mode 100644 index 09eef64b6e9b765fe57dc4872c4aed3f2db49362..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01017.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01017") -public class BenchmarkTest01017 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01017") != null) { - param = request.getHeader("BenchmarkTest01017"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a27056 = param; // assign - StringBuilder b27056 = new StringBuilder(a27056); // stick in stringbuilder - b27056.append(" SafeStuff"); // append some safe content - b27056.replace( - b27056.length() - "Chars".length(), - b27056.length(), - "Chars"); // replace some of the end content - java.util.HashMap map27056 = new java.util.HashMap(); - map27056.put("key27056", b27056.toString()); // put in a collection - String c27056 = (String) map27056.get("key27056"); // get it back out - String d27056 = c27056.substring(0, c27056.length() - 1); // extract most of it - String e27056 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d27056.getBytes()))); // B64 encode and decode it - String f27056 = e27056.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g27056 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g27056); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01018.java b/OWASP DATASET CLEANED/BenchmarkTest01018.java deleted file mode 100644 index ae80b050952aa3eaba0ce0c9d3363bb58f2e52d8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01018.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01018") -public class BenchmarkTest01018 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01018") != null) { - param = request.getHeader("BenchmarkTest01018"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01019.java b/OWASP DATASET CLEANED/BenchmarkTest01019.java deleted file mode 100644 index 0f3d50d248d4b25880c1aa0bca946a974440d57e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01019.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01019") -public class BenchmarkTest01019 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01019") != null) { - param = request.getHeader("BenchmarkTest01019"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01020.java b/OWASP DATASET CLEANED/BenchmarkTest01020.java deleted file mode 100644 index 17fbacd224e9ea76fd4bbcdfc20a9586164bb6ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01020.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01020") -public class BenchmarkTest01020 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01020") != null) { - param = request.getHeader("BenchmarkTest01020"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01021.java b/OWASP DATASET CLEANED/BenchmarkTest01021.java deleted file mode 100644 index 3c88951a3194e847a4164a800b0129152ad48cd7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01021.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01021") -public class BenchmarkTest01021 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01021") != null) { - param = request.getHeader("BenchmarkTest01021"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map16616 = new java.util.HashMap(); - map16616.put("keyA-16616", "a_Value"); // put some stuff in the collection - map16616.put("keyB-16616", param); // put it in a collection - map16616.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map16616.get("keyB-16616"); // get it back out - bar = (String) map16616.get("keyA-16616"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01022.java b/OWASP DATASET CLEANED/BenchmarkTest01022.java deleted file mode 100644 index e4273e020346db155c1958991c350d77941f1c39..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01022.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01022") -public class BenchmarkTest01022 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01022") != null) { - param = request.getHeader("BenchmarkTest01022"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01023.java b/OWASP DATASET CLEANED/BenchmarkTest01023.java deleted file mode 100644 index 394763570544c2fdadef3c7aaf6c7121d85a3156..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01023.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01023") -public class BenchmarkTest01023 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01023") != null) { - param = request.getHeader("BenchmarkTest01023"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01024.java b/OWASP DATASET CLEANED/BenchmarkTest01024.java deleted file mode 100644 index 1847b41a262bf0b94c43f9b0773914e7e2a29012..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01024.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01024") -public class BenchmarkTest01024 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01024") != null) { - param = request.getHeader("BenchmarkTest01024"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01025.java b/OWASP DATASET CLEANED/BenchmarkTest01025.java deleted file mode 100644 index d6dd08b6493aff87fd1b8e57145377b4a072f637..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01025.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01025") -public class BenchmarkTest01025 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01025") != null) { - param = request.getHeader("BenchmarkTest01025"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01026.java b/OWASP DATASET CLEANED/BenchmarkTest01026.java deleted file mode 100644 index 7fb206cc28ecf17924747a811583c05e3122f83d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01026.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01026") -public class BenchmarkTest01026 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01026") != null) { - param = request.getHeader("BenchmarkTest01026"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a11433 = param; // assign - StringBuilder b11433 = new StringBuilder(a11433); // stick in stringbuilder - b11433.append(" SafeStuff"); // append some safe content - b11433.replace( - b11433.length() - "Chars".length(), - b11433.length(), - "Chars"); // replace some of the end content - java.util.HashMap map11433 = new java.util.HashMap(); - map11433.put("key11433", b11433.toString()); // put in a collection - String c11433 = (String) map11433.get("key11433"); // get it back out - String d11433 = c11433.substring(0, c11433.length() - 1); // extract most of it - String e11433 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d11433.getBytes()))); // B64 encode and decode it - String f11433 = e11433.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g11433 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g11433); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01027.java b/OWASP DATASET CLEANED/BenchmarkTest01027.java deleted file mode 100644 index 6d299801597a9345831277619e336356357ce93c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01027.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01027") -public class BenchmarkTest01027 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01027") != null) { - param = request.getHeader("BenchmarkTest01027"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01028.java b/OWASP DATASET CLEANED/BenchmarkTest01028.java deleted file mode 100644 index 321b4efdd17e9d0b15fdbc8f521dab4654e8d798..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01028.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01028") -public class BenchmarkTest01028 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01028") != null) { - param = request.getHeader("BenchmarkTest01028"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01029.java b/OWASP DATASET CLEANED/BenchmarkTest01029.java deleted file mode 100644 index 5b0f984f8b15dfe785a33f3cffe7c9200cc22347..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01029.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01029") -public class BenchmarkTest01029 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01029") != null) { - param = request.getHeader("BenchmarkTest01029"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01030.java b/OWASP DATASET CLEANED/BenchmarkTest01030.java deleted file mode 100644 index b19d1b78391ca3b7bb6f424551bbec216ed58dff..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01030.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01030") -public class BenchmarkTest01030 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01030") != null) { - param = request.getHeader("BenchmarkTest01030"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01031.java b/OWASP DATASET CLEANED/BenchmarkTest01031.java deleted file mode 100644 index 2eace60d0fcae41fa73c4875062e43ab55deceb8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01031.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01031") -public class BenchmarkTest01031 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01031") != null) { - param = request.getHeader("BenchmarkTest01031"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01032.java b/OWASP DATASET CLEANED/BenchmarkTest01032.java deleted file mode 100644 index 5803e1eab2502792a34fb305e6526ac47f477eec..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01032.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01032") -public class BenchmarkTest01032 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01032") != null) { - param = request.getHeader("BenchmarkTest01032"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01033.java b/OWASP DATASET CLEANED/BenchmarkTest01033.java deleted file mode 100644 index 441af1d381522600595025b9b56529c4199eb769..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01033.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01033") -public class BenchmarkTest01033 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01033") != null) { - param = request.getHeader("BenchmarkTest01033"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01034.java b/OWASP DATASET CLEANED/BenchmarkTest01034.java deleted file mode 100644 index 4e5277f741d8c98c480740cc97f9c4417dc63f77..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01034.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01034") -public class BenchmarkTest01034 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01034") != null) { - param = request.getHeader("BenchmarkTest01034"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01035.java b/OWASP DATASET CLEANED/BenchmarkTest01035.java deleted file mode 100644 index 7b5680ec705b9472d995c625c017ed4691fe9c98..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01035.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01035") -public class BenchmarkTest01035 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01035") != null) { - param = request.getHeader("BenchmarkTest01035"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01036.java b/OWASP DATASET CLEANED/BenchmarkTest01036.java deleted file mode 100644 index 0104135b2abe678cbed4d7fd7b4fbd52f1c9e44a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01036.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01036") -public class BenchmarkTest01036 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01036") != null) { - param = request.getHeader("BenchmarkTest01036"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map8487 = new java.util.HashMap(); - map8487.put("keyA-8487", "a_Value"); // put some stuff in the collection - map8487.put("keyB-8487", param); // put it in a collection - map8487.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map8487.get("keyB-8487"); // get it back out - bar = (String) map8487.get("keyA-8487"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01037.java b/OWASP DATASET CLEANED/BenchmarkTest01037.java deleted file mode 100644 index df121f33a5150065c5b8e114a61cb6ef354f4bc8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01037.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01037") -public class BenchmarkTest01037 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01037") != null) { - param = request.getHeader("BenchmarkTest01037"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01038.java b/OWASP DATASET CLEANED/BenchmarkTest01038.java deleted file mode 100644 index 175c35430b56f0c9942140dddb79fa2aa1dda561..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01038.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01038") -public class BenchmarkTest01038 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01038") != null) { - param = request.getHeader("BenchmarkTest01038"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01039.java b/OWASP DATASET CLEANED/BenchmarkTest01039.java deleted file mode 100644 index ec15135fb46ec765e9da5caceba2abf38ecad238..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01039.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01039") -public class BenchmarkTest01039 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01039") != null) { - param = request.getHeader("BenchmarkTest01039"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01040.java b/OWASP DATASET CLEANED/BenchmarkTest01040.java deleted file mode 100644 index 1129b0ec9703387730dfb7bcd447cf8972a89ded..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01040.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01040") -public class BenchmarkTest01040 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01040") != null) { - param = request.getHeader("BenchmarkTest01040"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz96551 = new StringBuilder(param); - String bar = sbxyz96551.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01041.java b/OWASP DATASET CLEANED/BenchmarkTest01041.java deleted file mode 100644 index d2c16cdf745f2bcd3dcebba10f6799f7fd666d1f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01041.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01041") -public class BenchmarkTest01041 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01041") != null) { - param = request.getHeader("BenchmarkTest01041"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01042.java b/OWASP DATASET CLEANED/BenchmarkTest01042.java deleted file mode 100644 index 5fa97f7b4c32f914bb74c3dbedb0780a833e8e13..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01042.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01042") -public class BenchmarkTest01042 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01042") != null) { - param = request.getHeader("BenchmarkTest01042"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz89642 = new StringBuilder(param); - String bar = sbxyz89642.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01043.java b/OWASP DATASET CLEANED/BenchmarkTest01043.java deleted file mode 100644 index 050594ce6acba8f386c949e27942bfa7cdd253f6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01043.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01043") -public class BenchmarkTest01043 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01043") != null) { - param = request.getHeader("BenchmarkTest01043"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01044.java b/OWASP DATASET CLEANED/BenchmarkTest01044.java deleted file mode 100644 index 9ca6cfea3dba456fd7d60be6ee8dffe5190fd7d7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01044.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01044") -public class BenchmarkTest01044 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01044") != null) { - param = request.getHeader("BenchmarkTest01044"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01045.java b/OWASP DATASET CLEANED/BenchmarkTest01045.java deleted file mode 100644 index a823021b1aaf5ddb0f11966e00a944decc4497a7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01045.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01045") -public class BenchmarkTest01045 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01045") != null) { - param = request.getHeader("BenchmarkTest01045"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01046.java b/OWASP DATASET CLEANED/BenchmarkTest01046.java deleted file mode 100644 index 9c5514c12807ce789416ce31ecc8dbeec6c1b99e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01046.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest01046") -public class BenchmarkTest01046 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map95803 = new java.util.HashMap(); - map95803.put("keyA-95803", "a-Value"); // put some stuff in the collection - map95803.put("keyB-95803", param); // put it in a collection - map95803.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map95803.get("keyB-95803"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01047.java b/OWASP DATASET CLEANED/BenchmarkTest01047.java deleted file mode 100644 index 8753ffcd144d8c571f9dfc2eff7348685c87bbe7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01047.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-01/BenchmarkTest01047") -public class BenchmarkTest01047 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz50709 = new StringBuilder(param); - bar = - sbxyz50709 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01048.java b/OWASP DATASET CLEANED/BenchmarkTest01048.java deleted file mode 100644 index 471020ced32e4400219ae6d44c592595168c2555..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01048.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01048") -public class BenchmarkTest01048 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01049.java b/OWASP DATASET CLEANED/BenchmarkTest01049.java deleted file mode 100644 index 8483295669b9414dfae1b620cdbe7426736c0cab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01049.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01049") -public class BenchmarkTest01049 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01050.java b/OWASP DATASET CLEANED/BenchmarkTest01050.java deleted file mode 100644 index ef46df752b61b67149ca4557c5823f21a669d38e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01050.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01050") -public class BenchmarkTest01050 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz75528 = new StringBuilder(param); - String bar = sbxyz75528.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01051.java b/OWASP DATASET CLEANED/BenchmarkTest01051.java deleted file mode 100644 index 0d836ccbea47aa9d594d829a1854deb93b9a0b92..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01051.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01051") -public class BenchmarkTest01051 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01052.java b/OWASP DATASET CLEANED/BenchmarkTest01052.java deleted file mode 100644 index 728b8284b26cf730528b38484892b5a09eb0842c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01052.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01052") -public class BenchmarkTest01052 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01053.java b/OWASP DATASET CLEANED/BenchmarkTest01053.java deleted file mode 100644 index d9e7dfcf9b5d893465765a83e967880930c24668..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01053.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01053") -public class BenchmarkTest01053 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01054.java b/OWASP DATASET CLEANED/BenchmarkTest01054.java deleted file mode 100644 index 62d80bd5c5d2d0c3ca1a8930e79a7b9ef12aca77..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01054.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01054") -public class BenchmarkTest01054 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01055.java b/OWASP DATASET CLEANED/BenchmarkTest01055.java deleted file mode 100644 index 22c49c297c2866280816a20ba29eb46f4eacd6b3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01055.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01055") -public class BenchmarkTest01055 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01056.java b/OWASP DATASET CLEANED/BenchmarkTest01056.java deleted file mode 100644 index ea2e61787d10f91a61e786244a9acef695daac55..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01056.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01056") -public class BenchmarkTest01056 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01057.java b/OWASP DATASET CLEANED/BenchmarkTest01057.java deleted file mode 100644 index 1ef5e5965a630ea1d21e14354e3c1bbe75c60ec6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01057.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01057") -public class BenchmarkTest01057 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01058.java b/OWASP DATASET CLEANED/BenchmarkTest01058.java deleted file mode 100644 index 1be2852716d2ab2ee8e0406e385f798bde018727..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01058.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01058") -public class BenchmarkTest01058 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01058") != null) { - param = request.getHeader("BenchmarkTest01058"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz56505 = new StringBuilder(param); - String bar = sbxyz56505.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01059.java b/OWASP DATASET CLEANED/BenchmarkTest01059.java deleted file mode 100644 index 5910aca8dfc7b0e5bd35af5b1d942938e8ba15bd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01059.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01059") -public class BenchmarkTest01059 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01059") != null) { - param = request.getHeader("BenchmarkTest01059"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01060.java b/OWASP DATASET CLEANED/BenchmarkTest01060.java deleted file mode 100644 index 246ba5eafc6de90939a94c643021b6a5ebecd5fd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01060.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01060") -public class BenchmarkTest01060 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01060") != null) { - param = request.getHeader("BenchmarkTest01060"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01061.java b/OWASP DATASET CLEANED/BenchmarkTest01061.java deleted file mode 100644 index ff8b0dfd509ffcfda5f3198864d9480461b52aee..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01061.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01061") -public class BenchmarkTest01061 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01061") != null) { - param = request.getHeader("BenchmarkTest01061"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz37461 = new StringBuilder(param); - bar = - sbxyz37461 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01062.java b/OWASP DATASET CLEANED/BenchmarkTest01062.java deleted file mode 100644 index caea71c8d2e199951c415f69a653016d1e17d676..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01062.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01062") -public class BenchmarkTest01062 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01062") != null) { - param = request.getHeader("BenchmarkTest01062"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01063.java b/OWASP DATASET CLEANED/BenchmarkTest01063.java deleted file mode 100644 index 0a02f0f4dcd0bae26d47454a23682badf9de0dc1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01063.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01063") -public class BenchmarkTest01063 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a92400 = param; // assign - StringBuilder b92400 = new StringBuilder(a92400); // stick in stringbuilder - b92400.append(" SafeStuff"); // append some safe content - b92400.replace( - b92400.length() - "Chars".length(), - b92400.length(), - "Chars"); // replace some of the end content - java.util.HashMap map92400 = new java.util.HashMap(); - map92400.put("key92400", b92400.toString()); // put in a collection - String c92400 = (String) map92400.get("key92400"); // get it back out - String d92400 = c92400.substring(0, c92400.length() - 1); // extract most of it - String e92400 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d92400.getBytes()))); // B64 encode and decode it - String f92400 = e92400.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f92400); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01064.java b/OWASP DATASET CLEANED/BenchmarkTest01064.java deleted file mode 100644 index c5b774f8bb0df8eddab1bf7e9463a7d142d5293d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01064.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01064") -public class BenchmarkTest01064 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01064") != null) { - param = request.getHeader("BenchmarkTest01064"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map72463 = new java.util.HashMap(); - map72463.put("keyA-72463", "a-Value"); // put some stuff in the collection - map72463.put("keyB-72463", param); // put it in a collection - map72463.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map72463.get("keyB-72463"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01065.java b/OWASP DATASET CLEANED/BenchmarkTest01065.java deleted file mode 100644 index 5e682e30ff7e2d5f1f76636aba8e79686fa982d3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01065.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01065") -public class BenchmarkTest01065 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01065") != null) { - param = request.getHeader("BenchmarkTest01065"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01066.java b/OWASP DATASET CLEANED/BenchmarkTest01066.java deleted file mode 100644 index c6b5b67863555b4a2d09542c77240243bd03e964..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01066.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01066") -public class BenchmarkTest01066 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01066") != null) { - param = request.getHeader("BenchmarkTest01066"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01067.java b/OWASP DATASET CLEANED/BenchmarkTest01067.java deleted file mode 100644 index 836347a1e5b7470b7a08c14905173bd62388635d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01067.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01067") -public class BenchmarkTest01067 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01067") != null) { - param = request.getHeader("BenchmarkTest01067"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01068.java b/OWASP DATASET CLEANED/BenchmarkTest01068.java deleted file mode 100644 index 43e80840fdce8f773ed1208ccfeb216b0fda2a33..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01068.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01068") -public class BenchmarkTest01068 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01068") != null) { - param = request.getHeader("BenchmarkTest01068"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01069.java b/OWASP DATASET CLEANED/BenchmarkTest01069.java deleted file mode 100644 index 91616cd366fb1cc85e1174e44ad12b8919d4e8ee..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01069.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01069") -public class BenchmarkTest01069 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01069") != null) { - param = request.getHeader("BenchmarkTest01069"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01070.java b/OWASP DATASET CLEANED/BenchmarkTest01070.java deleted file mode 100644 index 5a1294825e281460cd853d2751b10d6079c6f79d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01070.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01070") -public class BenchmarkTest01070 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01070") != null) { - param = request.getHeader("BenchmarkTest01070"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a85812 = param; // assign - StringBuilder b85812 = new StringBuilder(a85812); // stick in stringbuilder - b85812.append(" SafeStuff"); // append some safe content - b85812.replace( - b85812.length() - "Chars".length(), - b85812.length(), - "Chars"); // replace some of the end content - java.util.HashMap map85812 = new java.util.HashMap(); - map85812.put("key85812", b85812.toString()); // put in a collection - String c85812 = (String) map85812.get("key85812"); // get it back out - String d85812 = c85812.substring(0, c85812.length() - 1); // extract most of it - String e85812 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d85812.getBytes()))); // B64 encode and decode it - String f85812 = e85812.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f85812); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01071.java b/OWASP DATASET CLEANED/BenchmarkTest01071.java deleted file mode 100644 index 4d1b5684e315f267b7133c18e036167edc7193af..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01071.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01071") -public class BenchmarkTest01071 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01071") != null) { - param = request.getHeader("BenchmarkTest01071"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01072.java b/OWASP DATASET CLEANED/BenchmarkTest01072.java deleted file mode 100644 index 56049dc4f7d42ccd40c14ae6fefa811bc57d9e39..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01072.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01072") -public class BenchmarkTest01072 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01072") != null) { - param = request.getHeader("BenchmarkTest01072"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01073.java b/OWASP DATASET CLEANED/BenchmarkTest01073.java deleted file mode 100644 index 4a8086a9895dc539023fd953f4097a85f6d9ff25..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01073.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01073") -public class BenchmarkTest01073 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01073") != null) { - param = request.getHeader("BenchmarkTest01073"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01074.java b/OWASP DATASET CLEANED/BenchmarkTest01074.java deleted file mode 100644 index e2d9c9f0a45683f513a53b8d28dea57ffd908ca2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01074.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01074") -public class BenchmarkTest01074 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01074") != null) { - param = request.getHeader("BenchmarkTest01074"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01075.java b/OWASP DATASET CLEANED/BenchmarkTest01075.java deleted file mode 100644 index b215c3aa16659c09a3b51517d4af585e502d7b6c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01075.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01075") -public class BenchmarkTest01075 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01075") != null) { - param = request.getHeader("BenchmarkTest01075"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01076.java b/OWASP DATASET CLEANED/BenchmarkTest01076.java deleted file mode 100644 index bae7a817a6b6f20f09dd33ac3d40329d2d69914f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01076.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01076") -public class BenchmarkTest01076 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01076") != null) { - param = request.getHeader("BenchmarkTest01076"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01077.java b/OWASP DATASET CLEANED/BenchmarkTest01077.java deleted file mode 100644 index 456dba17fce6b93fd74106d4f132282c6926b877..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01077.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01077") -public class BenchmarkTest01077 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01077") != null) { - param = request.getHeader("BenchmarkTest01077"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01078.java b/OWASP DATASET CLEANED/BenchmarkTest01078.java deleted file mode 100644 index f802b5a93c68aca3cca94aef971c48161086c1c8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01078.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01078") -public class BenchmarkTest01078 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01078") != null) { - param = request.getHeader("BenchmarkTest01078"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz97831 = new StringBuilder(param); - String bar = sbxyz97831.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01079.java b/OWASP DATASET CLEANED/BenchmarkTest01079.java deleted file mode 100644 index de7e540f921b45d7474704e654ac5151e22d2b4d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01079.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01079") -public class BenchmarkTest01079 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01079") != null) { - param = request.getHeader("BenchmarkTest01079"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01080.java b/OWASP DATASET CLEANED/BenchmarkTest01080.java deleted file mode 100644 index ed85ea3f34a818fe05b29c6d629cdaafe7ae2fc9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01080.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01080") -public class BenchmarkTest01080 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01080") != null) { - param = request.getHeader("BenchmarkTest01080"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01081.java b/OWASP DATASET CLEANED/BenchmarkTest01081.java deleted file mode 100644 index 5c226dae29ab5ca03b333bc7ff9cdf6f409b619f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01081.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01081") -public class BenchmarkTest01081 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01081") != null) { - param = request.getHeader("BenchmarkTest01081"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz55141 = new StringBuilder(param); - String bar = sbxyz55141.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01082.java b/OWASP DATASET CLEANED/BenchmarkTest01082.java deleted file mode 100644 index 63eb520007c53213ed79662aa3bcd0107d7cedc2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01082.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01082") -public class BenchmarkTest01082 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01082") != null) { - param = request.getHeader("BenchmarkTest01082"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01083.java b/OWASP DATASET CLEANED/BenchmarkTest01083.java deleted file mode 100644 index 8c35a3c0f423eac42ffe5f27eecf6be895a408c6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01083.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01083") -public class BenchmarkTest01083 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01083") != null) { - param = request.getHeader("BenchmarkTest01083"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01084.java b/OWASP DATASET CLEANED/BenchmarkTest01084.java deleted file mode 100644 index 39bc262d468f8fc4abd82bb81bfa8d5431f55f57..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01084.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01084") -public class BenchmarkTest01084 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01084") != null) { - param = request.getHeader("BenchmarkTest01084"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01085.java b/OWASP DATASET CLEANED/BenchmarkTest01085.java deleted file mode 100644 index 45313dc2d8aceb187898de3c977264a5410aac2b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01085.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01085") -public class BenchmarkTest01085 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01085") != null) { - param = request.getHeader("BenchmarkTest01085"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01086.java b/OWASP DATASET CLEANED/BenchmarkTest01086.java deleted file mode 100644 index 37cc237de21c929ceefef224613bc78d03db1b00..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01086.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01086") -public class BenchmarkTest01086 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01086") != null) { - param = request.getHeader("BenchmarkTest01086"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01087.java b/OWASP DATASET CLEANED/BenchmarkTest01087.java deleted file mode 100644 index 2dd40979a6ecff9fad30638c37580c8756e535d4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01087.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01087") -public class BenchmarkTest01087 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01087") != null) { - param = request.getHeader("BenchmarkTest01087"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01088.java b/OWASP DATASET CLEANED/BenchmarkTest01088.java deleted file mode 100644 index 14ff34be7a32bc04e0b03c37f0999d9baedb971c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01088.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01088") -public class BenchmarkTest01088 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01088") != null) { - param = request.getHeader("BenchmarkTest01088"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01089.java b/OWASP DATASET CLEANED/BenchmarkTest01089.java deleted file mode 100644 index e9a7614edd8b2d0c720f23b7d93dd0fed5ea7c84..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01089.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01089") -public class BenchmarkTest01089 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01089") != null) { - param = request.getHeader("BenchmarkTest01089"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map11607 = new java.util.HashMap(); - map11607.put("keyA-11607", "a_Value"); // put some stuff in the collection - map11607.put("keyB-11607", param); // put it in a collection - map11607.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map11607.get("keyB-11607"); // get it back out - bar = (String) map11607.get("keyA-11607"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01090.java b/OWASP DATASET CLEANED/BenchmarkTest01090.java deleted file mode 100644 index d32c576efb5ada406684b7fd5942bd6ca2c6244c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01090.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01090") -public class BenchmarkTest01090 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01090") != null) { - param = request.getHeader("BenchmarkTest01090"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map12212 = new java.util.HashMap(); - map12212.put("keyA-12212", "a-Value"); // put some stuff in the collection - map12212.put("keyB-12212", param); // put it in a collection - map12212.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map12212.get("keyB-12212"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01091.java b/OWASP DATASET CLEANED/BenchmarkTest01091.java deleted file mode 100644 index 742b793533bfa8cafc7a750b53230ab193abdcc9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01091.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01091") -public class BenchmarkTest01091 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01091") != null) { - param = request.getHeader("BenchmarkTest01091"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01092.java b/OWASP DATASET CLEANED/BenchmarkTest01092.java deleted file mode 100644 index ed043e74d73dbcfb9fa27a067fa62a809ecd93e6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01092.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01092") -public class BenchmarkTest01092 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01092") != null) { - param = request.getHeader("BenchmarkTest01092"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01093.java b/OWASP DATASET CLEANED/BenchmarkTest01093.java deleted file mode 100644 index f73991dd7bde0c4e17f01e03bf5de378ad5c0c58..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01093.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01093") -public class BenchmarkTest01093 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01093") != null) { - param = request.getHeader("BenchmarkTest01093"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map18142 = new java.util.HashMap(); - map18142.put("keyA-18142", "a-Value"); // put some stuff in the collection - map18142.put("keyB-18142", param); // put it in a collection - map18142.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map18142.get("keyB-18142"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01094.java b/OWASP DATASET CLEANED/BenchmarkTest01094.java deleted file mode 100644 index dd9b0be9f25e29893a9e30e1bc2692c1602879a7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01094.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01094") -public class BenchmarkTest01094 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01094") != null) { - param = request.getHeader("BenchmarkTest01094"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01095.java b/OWASP DATASET CLEANED/BenchmarkTest01095.java deleted file mode 100644 index 82b0497b36cd4db362c4f12c2a628d137536f6e5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01095.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01095") -public class BenchmarkTest01095 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01095") != null) { - param = request.getHeader("BenchmarkTest01095"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01096.java b/OWASP DATASET CLEANED/BenchmarkTest01096.java deleted file mode 100644 index 04df2c0a13e27b4a65c9dacb35d44a78abf37512..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01096.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01096") -public class BenchmarkTest01096 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01096") != null) { - param = request.getHeader("BenchmarkTest01096"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01097.java b/OWASP DATASET CLEANED/BenchmarkTest01097.java deleted file mode 100644 index a7b174be36e200c1b4fd6b9a202c6f164920564f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01097.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01097") -public class BenchmarkTest01097 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01097") != null) { - param = request.getHeader("BenchmarkTest01097"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01098.java b/OWASP DATASET CLEANED/BenchmarkTest01098.java deleted file mode 100644 index 7a6c3c44c775324e759adb221e0763ba1f597ef6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01098.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01098") -public class BenchmarkTest01098 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01098") != null) { - param = request.getHeader("BenchmarkTest01098"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01099.java b/OWASP DATASET CLEANED/BenchmarkTest01099.java deleted file mode 100644 index eac78a3fb079b636e5ec23402b18aa48b44a5d25..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01099.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01099") -public class BenchmarkTest01099 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map30744 = new java.util.HashMap(); - map30744.put("keyA-30744", "a_Value"); // put some stuff in the collection - map30744.put("keyB-30744", param); // put it in a collection - map30744.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map30744.get("keyB-30744"); // get it back out - bar = (String) map30744.get("keyA-30744"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01100.java b/OWASP DATASET CLEANED/BenchmarkTest01100.java deleted file mode 100644 index ab997b2ee8d70da999f288cf0f8b0cad284f841d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01100.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01100") -public class BenchmarkTest01100 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz90035 = new StringBuilder(param); - bar = - sbxyz90035 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01101.java b/OWASP DATASET CLEANED/BenchmarkTest01101.java deleted file mode 100644 index 6841d7c8db455e7e40d2c5ebf6b677c48dff70a2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01101.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01101") -public class BenchmarkTest01101 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01102.java b/OWASP DATASET CLEANED/BenchmarkTest01102.java deleted file mode 100644 index d22c06ddd7d373083144d05a1bdf39bc2ea23571..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01102.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01102") -public class BenchmarkTest01102 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map10086 = new java.util.HashMap(); - map10086.put("keyA-10086", "a-Value"); // put some stuff in the collection - map10086.put("keyB-10086", param); // put it in a collection - map10086.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map10086.get("keyB-10086"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01103.java b/OWASP DATASET CLEANED/BenchmarkTest01103.java deleted file mode 100644 index 994f65eb68001bcd651412d3c28b5e8c567be0b8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01103.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01103") -public class BenchmarkTest01103 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01104.java b/OWASP DATASET CLEANED/BenchmarkTest01104.java deleted file mode 100644 index 79b0ed2d9027d2ffc01eae5af48af372a16f0a4e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01104.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01104") -public class BenchmarkTest01104 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01105.java b/OWASP DATASET CLEANED/BenchmarkTest01105.java deleted file mode 100644 index 6a33470a28f80a71276191b2d1edce8197e51797..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01105.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01105") -public class BenchmarkTest01105 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01106.java b/OWASP DATASET CLEANED/BenchmarkTest01106.java deleted file mode 100644 index 1857d3595ce051c317d7ecd7d9f3b3b74ea2c080..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01106.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01106") -public class BenchmarkTest01106 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01107.java b/OWASP DATASET CLEANED/BenchmarkTest01107.java deleted file mode 100644 index 41a8570d608a80c7d2c5d608bdc7087f1f10af09..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01107.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01107") -public class BenchmarkTest01107 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01108.java b/OWASP DATASET CLEANED/BenchmarkTest01108.java deleted file mode 100644 index abadd33199ac34dec7aee3d44e9b066c763f3380..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01108.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01108") -public class BenchmarkTest01108 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01109.java b/OWASP DATASET CLEANED/BenchmarkTest01109.java deleted file mode 100644 index c3b3a4aa98c310451f7aa96176497e842aebdf27..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01109.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01109") -public class BenchmarkTest01109 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a87030 = param; // assign - StringBuilder b87030 = new StringBuilder(a87030); // stick in stringbuilder - b87030.append(" SafeStuff"); // append some safe content - b87030.replace( - b87030.length() - "Chars".length(), - b87030.length(), - "Chars"); // replace some of the end content - java.util.HashMap map87030 = new java.util.HashMap(); - map87030.put("key87030", b87030.toString()); // put in a collection - String c87030 = (String) map87030.get("key87030"); // get it back out - String d87030 = c87030.substring(0, c87030.length() - 1); // extract most of it - String e87030 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d87030.getBytes()))); // B64 encode and decode it - String f87030 = e87030.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g87030 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g87030); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01110.java b/OWASP DATASET CLEANED/BenchmarkTest01110.java deleted file mode 100644 index e13828e1fb96e949453077f5d4c3ace5fc867070..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01110.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01110") -public class BenchmarkTest01110 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01111.java b/OWASP DATASET CLEANED/BenchmarkTest01111.java deleted file mode 100644 index 92cb3b991043d78ce50e9e81ff8a7efba023cae1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01111.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01111") -public class BenchmarkTest01111 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01112.java b/OWASP DATASET CLEANED/BenchmarkTest01112.java deleted file mode 100644 index 83ef692936e1cd189f461c150bb2f4531bfdf7bf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01112.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01112") -public class BenchmarkTest01112 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01113.java b/OWASP DATASET CLEANED/BenchmarkTest01113.java deleted file mode 100644 index ba36392041aa7aa97286163a26f68c2987a21592..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01113.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01113") -public class BenchmarkTest01113 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map50384 = new java.util.HashMap(); - map50384.put("keyA-50384", "a_Value"); // put some stuff in the collection - map50384.put("keyB-50384", param); // put it in a collection - map50384.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map50384.get("keyB-50384"); // get it back out - bar = (String) map50384.get("keyA-50384"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01114.java b/OWASP DATASET CLEANED/BenchmarkTest01114.java deleted file mode 100644 index b696e8e873044bb7c84f69961d384be5594af848..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01114.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01114") -public class BenchmarkTest01114 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a97099 = param; // assign - StringBuilder b97099 = new StringBuilder(a97099); // stick in stringbuilder - b97099.append(" SafeStuff"); // append some safe content - b97099.replace( - b97099.length() - "Chars".length(), - b97099.length(), - "Chars"); // replace some of the end content - java.util.HashMap map97099 = new java.util.HashMap(); - map97099.put("key97099", b97099.toString()); // put in a collection - String c97099 = (String) map97099.get("key97099"); // get it back out - String d97099 = c97099.substring(0, c97099.length() - 1); // extract most of it - String e97099 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d97099.getBytes()))); // B64 encode and decode it - String f97099 = e97099.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g97099 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g97099); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01115.java b/OWASP DATASET CLEANED/BenchmarkTest01115.java deleted file mode 100644 index 3a348c1ccdc66aa748f74a3b784f66ed1399fc68..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01115.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01115") -public class BenchmarkTest01115 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a43762 = param; // assign - StringBuilder b43762 = new StringBuilder(a43762); // stick in stringbuilder - b43762.append(" SafeStuff"); // append some safe content - b43762.replace( - b43762.length() - "Chars".length(), - b43762.length(), - "Chars"); // replace some of the end content - java.util.HashMap map43762 = new java.util.HashMap(); - map43762.put("key43762", b43762.toString()); // put in a collection - String c43762 = (String) map43762.get("key43762"); // get it back out - String d43762 = c43762.substring(0, c43762.length() - 1); // extract most of it - String e43762 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d43762.getBytes()))); // B64 encode and decode it - String f43762 = e43762.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g43762 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g43762); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01116.java b/OWASP DATASET CLEANED/BenchmarkTest01116.java deleted file mode 100644 index f9904a651c3f982f167552f60f94869312563aa1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01116.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01116") -public class BenchmarkTest01116 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01117.java b/OWASP DATASET CLEANED/BenchmarkTest01117.java deleted file mode 100644 index dc25a45f6e15ce35fa91b7726a8e4c70fdaefbaf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01117.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01117") -public class BenchmarkTest01117 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01118.java b/OWASP DATASET CLEANED/BenchmarkTest01118.java deleted file mode 100644 index 1209b84a73bbf5664f5bf64b812566b760e6e993..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01118.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01118") -public class BenchmarkTest01118 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map63904 = new java.util.HashMap(); - map63904.put("keyA-63904", "a_Value"); // put some stuff in the collection - map63904.put("keyB-63904", param); // put it in a collection - map63904.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map63904.get("keyB-63904"); // get it back out - bar = (String) map63904.get("keyA-63904"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01119.java b/OWASP DATASET CLEANED/BenchmarkTest01119.java deleted file mode 100644 index c0b5e4a2cc1b9ec9c726235182dab5a0fd65cbe3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01119.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01119") -public class BenchmarkTest01119 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01120.java b/OWASP DATASET CLEANED/BenchmarkTest01120.java deleted file mode 100644 index 788b425ba3340943e0a79299b20292a7e79d4d7d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01120.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01120") -public class BenchmarkTest01120 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a99915 = param; // assign - StringBuilder b99915 = new StringBuilder(a99915); // stick in stringbuilder - b99915.append(" SafeStuff"); // append some safe content - b99915.replace( - b99915.length() - "Chars".length(), - b99915.length(), - "Chars"); // replace some of the end content - java.util.HashMap map99915 = new java.util.HashMap(); - map99915.put("key99915", b99915.toString()); // put in a collection - String c99915 = (String) map99915.get("key99915"); // get it back out - String d99915 = c99915.substring(0, c99915.length() - 1); // extract most of it - String e99915 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d99915.getBytes()))); // B64 encode and decode it - String f99915 = e99915.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f99915); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01121.java b/OWASP DATASET CLEANED/BenchmarkTest01121.java deleted file mode 100644 index 8df9c5bfc5bf96dbf675ed56720be177fa0cc0de..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01121.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01121") -public class BenchmarkTest01121 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz22801 = new StringBuilder(param); - String bar = sbxyz22801.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01122.java b/OWASP DATASET CLEANED/BenchmarkTest01122.java deleted file mode 100644 index 8b1c738d932604a7516684096d5e11bff23c1625..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01122.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01122") -public class BenchmarkTest01122 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01123.java b/OWASP DATASET CLEANED/BenchmarkTest01123.java deleted file mode 100644 index 15992f6c66837363b67ff8bcb2218237ac325cb2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01123.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01123") -public class BenchmarkTest01123 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01124.java b/OWASP DATASET CLEANED/BenchmarkTest01124.java deleted file mode 100644 index a9beaeafa567f92075a77f51b63dd480729b5257..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01124.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01124") -public class BenchmarkTest01124 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map74702 = new java.util.HashMap(); - map74702.put("keyA-74702", "a_Value"); // put some stuff in the collection - map74702.put("keyB-74702", param); // put it in a collection - map74702.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map74702.get("keyB-74702"); // get it back out - bar = (String) map74702.get("keyA-74702"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01125.java b/OWASP DATASET CLEANED/BenchmarkTest01125.java deleted file mode 100644 index 21bb95d113d3ddc1e0277a38271873fc368797d7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01125.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01125") -public class BenchmarkTest01125 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01126.java b/OWASP DATASET CLEANED/BenchmarkTest01126.java deleted file mode 100644 index 27fb90364f6dcf2f92ed6f290b70b85f4cfe6b41..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01126.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01126") -public class BenchmarkTest01126 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01127.java b/OWASP DATASET CLEANED/BenchmarkTest01127.java deleted file mode 100644 index 2f6aa0b6fba0946a8888af98fe9d98e1a7318684..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01127.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01127") -public class BenchmarkTest01127 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01128.java b/OWASP DATASET CLEANED/BenchmarkTest01128.java deleted file mode 100644 index 4f6f5c5231af8e421908e00f443a2ac204858434..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01128.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01128") -public class BenchmarkTest01128 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz90224 = new StringBuilder(param); - bar = - sbxyz90224 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01129.java b/OWASP DATASET CLEANED/BenchmarkTest01129.java deleted file mode 100644 index 8e6f60544adcbad056021f666da31c5705ac519e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01129.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01129") -public class BenchmarkTest01129 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01130.java b/OWASP DATASET CLEANED/BenchmarkTest01130.java deleted file mode 100644 index a8e858743ea785cbaec52e4e5b4affe6ea9c507e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01130.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01130") -public class BenchmarkTest01130 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01131.java b/OWASP DATASET CLEANED/BenchmarkTest01131.java deleted file mode 100644 index e1abf7345352cd43bc753b1a1853376a72287340..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01131.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01131") -public class BenchmarkTest01131 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01132.java b/OWASP DATASET CLEANED/BenchmarkTest01132.java deleted file mode 100644 index 19d1cf25d8a703009c179e682175416f0ddd219e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01132.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01132") -public class BenchmarkTest01132 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01133.java b/OWASP DATASET CLEANED/BenchmarkTest01133.java deleted file mode 100644 index 5cd6a82d9adadcb2976e326003d56ea073af3b65..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01133.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01133") -public class BenchmarkTest01133 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01134.java b/OWASP DATASET CLEANED/BenchmarkTest01134.java deleted file mode 100644 index d2034ebfce58952a4576b40c925f9462b2c75f7e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01134.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01134") -public class BenchmarkTest01134 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map9728 = new java.util.HashMap(); - map9728.put("keyA-9728", "a-Value"); // put some stuff in the collection - map9728.put("keyB-9728", param); // put it in a collection - map9728.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map9728.get("keyB-9728"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01135.java b/OWASP DATASET CLEANED/BenchmarkTest01135.java deleted file mode 100644 index d0997ff21d9dd8fc71cb9cd6713ec18996a0c350..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01135.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01135") -public class BenchmarkTest01135 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01136.java b/OWASP DATASET CLEANED/BenchmarkTest01136.java deleted file mode 100644 index 63fbc6b1065bccf0fd13c9d451472e45413b801f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01136.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01136") -public class BenchmarkTest01136 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a58606 = param; // assign - StringBuilder b58606 = new StringBuilder(a58606); // stick in stringbuilder - b58606.append(" SafeStuff"); // append some safe content - b58606.replace( - b58606.length() - "Chars".length(), - b58606.length(), - "Chars"); // replace some of the end content - java.util.HashMap map58606 = new java.util.HashMap(); - map58606.put("key58606", b58606.toString()); // put in a collection - String c58606 = (String) map58606.get("key58606"); // get it back out - String d58606 = c58606.substring(0, c58606.length() - 1); // extract most of it - String e58606 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d58606.getBytes()))); // B64 encode and decode it - String f58606 = e58606.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g58606 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g58606); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01137.java b/OWASP DATASET CLEANED/BenchmarkTest01137.java deleted file mode 100644 index fd51863df6abc28f707572d97e555e1f4abc9903..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01137.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01137") -public class BenchmarkTest01137 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz8314 = new StringBuilder(param); - String bar = sbxyz8314.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01138.java b/OWASP DATASET CLEANED/BenchmarkTest01138.java deleted file mode 100644 index 6a1fc63c940708388154ad91c8290e5dc907b553..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01138.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01138") -public class BenchmarkTest01138 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz47470 = new StringBuilder(param); - bar = - sbxyz47470 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01139.java b/OWASP DATASET CLEANED/BenchmarkTest01139.java deleted file mode 100644 index 40737e19175082b65f8e5b905001eb68ec84d9c8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01139.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01139") -public class BenchmarkTest01139 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz40917 = new StringBuilder(param); - bar = - sbxyz40917 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01140.java b/OWASP DATASET CLEANED/BenchmarkTest01140.java deleted file mode 100644 index e48a1dbf620f76631f7b15b92e4c640d7ad61a18..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01140.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01140") -public class BenchmarkTest01140 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a25760 = param; // assign - StringBuilder b25760 = new StringBuilder(a25760); // stick in stringbuilder - b25760.append(" SafeStuff"); // append some safe content - b25760.replace( - b25760.length() - "Chars".length(), - b25760.length(), - "Chars"); // replace some of the end content - java.util.HashMap map25760 = new java.util.HashMap(); - map25760.put("key25760", b25760.toString()); // put in a collection - String c25760 = (String) map25760.get("key25760"); // get it back out - String d25760 = c25760.substring(0, c25760.length() - 1); // extract most of it - String e25760 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d25760.getBytes()))); // B64 encode and decode it - String f25760 = e25760.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g25760 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g25760); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01141.java b/OWASP DATASET CLEANED/BenchmarkTest01141.java deleted file mode 100644 index bc54bd91babace6bcfa6c7a7d3477590472c5827..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01141.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01141") -public class BenchmarkTest01141 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz2940 = new StringBuilder(param); - bar = - sbxyz2940 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01142.java b/OWASP DATASET CLEANED/BenchmarkTest01142.java deleted file mode 100644 index 749b2312fcdd787e78a5d5b9070a69b0a4ecfbd2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01142.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01142") -public class BenchmarkTest01142 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01143.java b/OWASP DATASET CLEANED/BenchmarkTest01143.java deleted file mode 100644 index 85bfcbef88bd0fab883e97cfa7329a3ef8313bc1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01143.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01143") -public class BenchmarkTest01143 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz70712 = new StringBuilder(param); - String bar = sbxyz70712.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01144.java b/OWASP DATASET CLEANED/BenchmarkTest01144.java deleted file mode 100644 index 7402fce99de2d93c13070596256ec8ce5319cac8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01144.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01144") -public class BenchmarkTest01144 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01145.java b/OWASP DATASET CLEANED/BenchmarkTest01145.java deleted file mode 100644 index d5f1c56669c5501cc7723650bb57083c32ae3af0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01145.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01145") -public class BenchmarkTest01145 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01146.java b/OWASP DATASET CLEANED/BenchmarkTest01146.java deleted file mode 100644 index f9059723732d1e23c3a212177f834e9502309947..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01146.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01146") -public class BenchmarkTest01146 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01147.java b/OWASP DATASET CLEANED/BenchmarkTest01147.java deleted file mode 100644 index 9fdb38dee8534ce34e5ea0a643657d61cad2adc5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01147.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01147") -public class BenchmarkTest01147 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01147"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz71288 = new StringBuilder(param); - bar = - sbxyz71288 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01148.java b/OWASP DATASET CLEANED/BenchmarkTest01148.java deleted file mode 100644 index 91a5223f7618db0964b75561bbd3a4055397f154..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01148.java +++ /dev/null @@ -1,175 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01148") -public class BenchmarkTest01148 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01148"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01149.java b/OWASP DATASET CLEANED/BenchmarkTest01149.java deleted file mode 100644 index 0a96d7db708bdb744e0590f085df97d6c0ad4560..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01149.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01149") -public class BenchmarkTest01149 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01149"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01150.java b/OWASP DATASET CLEANED/BenchmarkTest01150.java deleted file mode 100644 index 786968376efa91c7ba4e9edfba4d453e6575404d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01150.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01150") -public class BenchmarkTest01150 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01150"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01151.java b/OWASP DATASET CLEANED/BenchmarkTest01151.java deleted file mode 100644 index c056f4be4884aee24da2124eb576f05d6741d596..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01151.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01151") -public class BenchmarkTest01151 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01151"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01152.java b/OWASP DATASET CLEANED/BenchmarkTest01152.java deleted file mode 100644 index 9b7e57532b395fe550cc47b7b22ad187ca904495..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01152.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01152") -public class BenchmarkTest01152 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01152"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01153.java b/OWASP DATASET CLEANED/BenchmarkTest01153.java deleted file mode 100644 index cdea093b1e249101baed0b7384d78576d6a86920..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01153.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01153") -public class BenchmarkTest01153 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01153"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a2387 = param; // assign - StringBuilder b2387 = new StringBuilder(a2387); // stick in stringbuilder - b2387.append(" SafeStuff"); // append some safe content - b2387.replace( - b2387.length() - "Chars".length(), - b2387.length(), - "Chars"); // replace some of the end content - java.util.HashMap map2387 = new java.util.HashMap(); - map2387.put("key2387", b2387.toString()); // put in a collection - String c2387 = (String) map2387.get("key2387"); // get it back out - String d2387 = c2387.substring(0, c2387.length() - 1); // extract most of it - String e2387 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d2387.getBytes()))); // B64 encode and decode it - String f2387 = e2387.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g2387 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g2387); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01154.java b/OWASP DATASET CLEANED/BenchmarkTest01154.java deleted file mode 100644 index 1ef4bfffe73d38f0854ffef83ebc54d9f5e7cd22..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01154.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01154") -public class BenchmarkTest01154 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01154"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01155.java b/OWASP DATASET CLEANED/BenchmarkTest01155.java deleted file mode 100644 index a1f290241296f892843e0822fbaf3bf2ba23e3db..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01155.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01155") -public class BenchmarkTest01155 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01155"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01156.java b/OWASP DATASET CLEANED/BenchmarkTest01156.java deleted file mode 100644 index fa51554c958592d81fe43d65e001b072c282b658..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01156.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01156") -public class BenchmarkTest01156 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01156"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map55476 = new java.util.HashMap(); - map55476.put("keyA-55476", "a-Value"); // put some stuff in the collection - map55476.put("keyB-55476", param); // put it in a collection - map55476.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map55476.get("keyB-55476"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01157.java b/OWASP DATASET CLEANED/BenchmarkTest01157.java deleted file mode 100644 index 6fe7bf2e109bda1dc13df7ba6e29d2f9911acd2a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01157.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01157") -public class BenchmarkTest01157 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01157"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01158.java b/OWASP DATASET CLEANED/BenchmarkTest01158.java deleted file mode 100644 index e21ec0b496f792056c2adf74de6c5a11bf57aa63..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01158.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01158") -public class BenchmarkTest01158 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01158"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01159.java b/OWASP DATASET CLEANED/BenchmarkTest01159.java deleted file mode 100644 index 6fef40ca2f5a1ccea4b1884d31fe64dda7171935..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01159.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01159") -public class BenchmarkTest01159 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01159"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a54259 = param; // assign - StringBuilder b54259 = new StringBuilder(a54259); // stick in stringbuilder - b54259.append(" SafeStuff"); // append some safe content - b54259.replace( - b54259.length() - "Chars".length(), - b54259.length(), - "Chars"); // replace some of the end content - java.util.HashMap map54259 = new java.util.HashMap(); - map54259.put("key54259", b54259.toString()); // put in a collection - String c54259 = (String) map54259.get("key54259"); // get it back out - String d54259 = c54259.substring(0, c54259.length() - 1); // extract most of it - String e54259 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d54259.getBytes()))); // B64 encode and decode it - String f54259 = e54259.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g54259 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g54259); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01160.java b/OWASP DATASET CLEANED/BenchmarkTest01160.java deleted file mode 100644 index 78cdc16f89dfd6567b065d672c3d2f79fa77ccd3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01160.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01160") -public class BenchmarkTest01160 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01160"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01161.java b/OWASP DATASET CLEANED/BenchmarkTest01161.java deleted file mode 100644 index 007756fe6aeb35373fcb770cc606ff637f0c9ddd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01161.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01161") -public class BenchmarkTest01161 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01161"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01162.java b/OWASP DATASET CLEANED/BenchmarkTest01162.java deleted file mode 100644 index 92d5140fb5103e655bd270fd6abd9f09c6140e2f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01162.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01162") -public class BenchmarkTest01162 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01162"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map72162 = new java.util.HashMap(); - map72162.put("keyA-72162", "a_Value"); // put some stuff in the collection - map72162.put("keyB-72162", param); // put it in a collection - map72162.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map72162.get("keyB-72162"); // get it back out - bar = (String) map72162.get("keyA-72162"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01163.java b/OWASP DATASET CLEANED/BenchmarkTest01163.java deleted file mode 100644 index c9aecb932600d5437d61da653ed62ed048bc1170..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01163.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01163") -public class BenchmarkTest01163 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01163"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01164.java b/OWASP DATASET CLEANED/BenchmarkTest01164.java deleted file mode 100644 index ef2641b4e9b6e2181adc0f0889fcd7e0d5ed4977..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01164.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01164") -public class BenchmarkTest01164 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01164"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01165.java b/OWASP DATASET CLEANED/BenchmarkTest01165.java deleted file mode 100644 index f0ce54a8a86f6a82d11edf2458e7b2f3edb8feaa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01165.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01165") -public class BenchmarkTest01165 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01165"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a91034 = param; // assign - StringBuilder b91034 = new StringBuilder(a91034); // stick in stringbuilder - b91034.append(" SafeStuff"); // append some safe content - b91034.replace( - b91034.length() - "Chars".length(), - b91034.length(), - "Chars"); // replace some of the end content - java.util.HashMap map91034 = new java.util.HashMap(); - map91034.put("key91034", b91034.toString()); // put in a collection - String c91034 = (String) map91034.get("key91034"); // get it back out - String d91034 = c91034.substring(0, c91034.length() - 1); // extract most of it - String e91034 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d91034.getBytes()))); // B64 encode and decode it - String f91034 = e91034.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g91034 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g91034); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01166.java b/OWASP DATASET CLEANED/BenchmarkTest01166.java deleted file mode 100644 index 1870e695ed4561b10da6a9a7e5dbb9580d2d65df..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01166.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01166") -public class BenchmarkTest01166 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01166"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz52006 = new StringBuilder(param); - bar = - sbxyz52006 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01167.java b/OWASP DATASET CLEANED/BenchmarkTest01167.java deleted file mode 100644 index 2521fc5b8e2b1e60e7866354e646c221e4ce5153..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01167.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01167") -public class BenchmarkTest01167 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01167"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map70586 = new java.util.HashMap(); - map70586.put("keyA-70586", "a-Value"); // put some stuff in the collection - map70586.put("keyB-70586", param); // put it in a collection - map70586.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map70586.get("keyB-70586"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01168.java b/OWASP DATASET CLEANED/BenchmarkTest01168.java deleted file mode 100644 index 55f37e7aac0dafe3b973817000da01ed8da57024..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01168.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01168") -public class BenchmarkTest01168 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01168"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01169.java b/OWASP DATASET CLEANED/BenchmarkTest01169.java deleted file mode 100644 index 4530d133a60f1998216fb7107df3b0aa1a645afa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01169.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01169") -public class BenchmarkTest01169 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01169"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01170.java b/OWASP DATASET CLEANED/BenchmarkTest01170.java deleted file mode 100644 index 6c2b0c0bf0acc825e2a0011f5aea3af0821061e5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01170.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01170") -public class BenchmarkTest01170 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01170"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01171.java b/OWASP DATASET CLEANED/BenchmarkTest01171.java deleted file mode 100644 index ff1a002a02ac0c471563c4c4821cccf3961b60f1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01171.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01171") -public class BenchmarkTest01171 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz83647 = new StringBuilder(param); - bar = - sbxyz83647 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01172.java b/OWASP DATASET CLEANED/BenchmarkTest01172.java deleted file mode 100644 index 77d967e09bfb5aa9a67b1c26e7c9997303022dab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01172.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01172") -public class BenchmarkTest01172 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map35084 = new java.util.HashMap(); - map35084.put("keyA-35084", "a-Value"); // put some stuff in the collection - map35084.put("keyB-35084", param); // put it in a collection - map35084.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map35084.get("keyB-35084"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01173.java b/OWASP DATASET CLEANED/BenchmarkTest01173.java deleted file mode 100644 index 105a919ff8eebcb2b2fbc274242e24d85eb987b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01173.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01173") -public class BenchmarkTest01173 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01174.java b/OWASP DATASET CLEANED/BenchmarkTest01174.java deleted file mode 100644 index b96d9dffc803e5e58f7d85c39babb0a817836e26..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01174.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01174") -public class BenchmarkTest01174 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01175.java b/OWASP DATASET CLEANED/BenchmarkTest01175.java deleted file mode 100644 index 0a86c428516219401ec091d2c110a8c257f4107d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01175.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01175") -public class BenchmarkTest01175 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01176.java b/OWASP DATASET CLEANED/BenchmarkTest01176.java deleted file mode 100644 index 78ec83258b48f1ac237bbbd55949c2e2387db453..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01176.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01176") -public class BenchmarkTest01176 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01177.java b/OWASP DATASET CLEANED/BenchmarkTest01177.java deleted file mode 100644 index 015ae9f4a86d12639fb722afd252fdc991179b1c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01177.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01177") -public class BenchmarkTest01177 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01178.java b/OWASP DATASET CLEANED/BenchmarkTest01178.java deleted file mode 100644 index 81e39130636391f65f8144779539a181fafc2a85..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01178.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01178") -public class BenchmarkTest01178 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz69428 = new StringBuilder(param); - String bar = sbxyz69428.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01179.java b/OWASP DATASET CLEANED/BenchmarkTest01179.java deleted file mode 100644 index 3ab24e899ef725a11d1f4570bd58ee08f411bae9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01179.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01179") -public class BenchmarkTest01179 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01180.java b/OWASP DATASET CLEANED/BenchmarkTest01180.java deleted file mode 100644 index ea0bbd158ea41736ae5dcc1f2220dd542dc4d64a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01180.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01180") -public class BenchmarkTest01180 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01181.java b/OWASP DATASET CLEANED/BenchmarkTest01181.java deleted file mode 100644 index bfe1a561c997e208a4eaa7a643ef2acf9a006e78..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01181.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01181") -public class BenchmarkTest01181 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01182.java b/OWASP DATASET CLEANED/BenchmarkTest01182.java deleted file mode 100644 index ff6b5c3a2a3f6f097aecda1b622bb6b9d8aecfca..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01182.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01182") -public class BenchmarkTest01182 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01182"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01183.java b/OWASP DATASET CLEANED/BenchmarkTest01183.java deleted file mode 100644 index b2e2363a8aa2bea3033e7da5f811ef4185704889..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01183.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01183") -public class BenchmarkTest01183 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01183"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01184.java b/OWASP DATASET CLEANED/BenchmarkTest01184.java deleted file mode 100644 index d190368fae302ff8df07d9d9786f65e4270a96e1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01184.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01184") -public class BenchmarkTest01184 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01184"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01185.java b/OWASP DATASET CLEANED/BenchmarkTest01185.java deleted file mode 100644 index e72afce89427a659bd433938e56b20b9c1df2ff8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01185.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01185") -public class BenchmarkTest01185 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01185"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01186.java b/OWASP DATASET CLEANED/BenchmarkTest01186.java deleted file mode 100644 index 387dd3148413d7031d06a382984efa4b881cd927..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01186.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01186") -public class BenchmarkTest01186 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01186"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01187.java b/OWASP DATASET CLEANED/BenchmarkTest01187.java deleted file mode 100644 index 801a5df382afedf50ed4294171c6938461e38dac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01187.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01187") -public class BenchmarkTest01187 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01187"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01188.java b/OWASP DATASET CLEANED/BenchmarkTest01188.java deleted file mode 100644 index bb5ae988893e104246d3ccd09be51b4456a5b23a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01188.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01188") -public class BenchmarkTest01188 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01189.java b/OWASP DATASET CLEANED/BenchmarkTest01189.java deleted file mode 100644 index e0f9841e5ad59c75e9692b3dd2806ba672b20085..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01189.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01189") -public class BenchmarkTest01189 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01189"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01190.java b/OWASP DATASET CLEANED/BenchmarkTest01190.java deleted file mode 100644 index f222fea52697b69eac9dbf417999c8bc6f850dc1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01190.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01190") -public class BenchmarkTest01190 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01190"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01191.java b/OWASP DATASET CLEANED/BenchmarkTest01191.java deleted file mode 100644 index 99901bd4908eb71545de53fdb7a91f41b6ef5ab2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01191.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01191") -public class BenchmarkTest01191 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01191"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01192.java b/OWASP DATASET CLEANED/BenchmarkTest01192.java deleted file mode 100644 index 0ac03a63dab75b53f3ae1b783f92f9159cd71090..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01192.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01192") -public class BenchmarkTest01192 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01192"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01193.java b/OWASP DATASET CLEANED/BenchmarkTest01193.java deleted file mode 100644 index 48ec2e5ead7dfc320ecb41f40da88842421fe994..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01193.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01193") -public class BenchmarkTest01193 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01193"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01194.java b/OWASP DATASET CLEANED/BenchmarkTest01194.java deleted file mode 100644 index af7933405bf8c495de0cf5aeeadce61fab15d2d2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01194.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01194") -public class BenchmarkTest01194 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01194"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01195.java b/OWASP DATASET CLEANED/BenchmarkTest01195.java deleted file mode 100644 index 11a6d128aec27da744149056a180f4821ebb37c1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01195.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01195") -public class BenchmarkTest01195 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01195"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01196.java b/OWASP DATASET CLEANED/BenchmarkTest01196.java deleted file mode 100644 index fae24539471af98926521752b24675f670253a68..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01196.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01196") -public class BenchmarkTest01196 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01196"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01197.java b/OWASP DATASET CLEANED/BenchmarkTest01197.java deleted file mode 100644 index ac1e5a8d248a916745c6905af7842cae494c7ef7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01197.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01197") -public class BenchmarkTest01197 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01197"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz6066 = new StringBuilder(param); - String bar = sbxyz6066.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01198.java b/OWASP DATASET CLEANED/BenchmarkTest01198.java deleted file mode 100644 index 252663997787ccec563ff3c5e8fc8dfe9855e1d6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01198.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01198") -public class BenchmarkTest01198 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01198"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01199.java b/OWASP DATASET CLEANED/BenchmarkTest01199.java deleted file mode 100644 index d10984947cf6ed96998d8ab928293bb13a03a907..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01199.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01199") -public class BenchmarkTest01199 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01199"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01200.java b/OWASP DATASET CLEANED/BenchmarkTest01200.java deleted file mode 100644 index 34974a7e54dfe3ea03784526a0c548cfa8b7b980..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01200.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01200") -public class BenchmarkTest01200 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01200"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01201.java b/OWASP DATASET CLEANED/BenchmarkTest01201.java deleted file mode 100644 index 591136e77e88275bf366e31e2bab848cdce149f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01201.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01201") -public class BenchmarkTest01201 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01201"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01202.java b/OWASP DATASET CLEANED/BenchmarkTest01202.java deleted file mode 100644 index 1e76029a311e4046224dad35e33f23ef339bf4d6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01202.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01202") -public class BenchmarkTest01202 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01202"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01203.java b/OWASP DATASET CLEANED/BenchmarkTest01203.java deleted file mode 100644 index 0ea42f82de80e601a44a276a5b5b5e2f440c7bac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01203.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01203") -public class BenchmarkTest01203 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01203"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map72700 = new java.util.HashMap(); - map72700.put("keyA-72700", "a-Value"); // put some stuff in the collection - map72700.put("keyB-72700", param); // put it in a collection - map72700.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map72700.get("keyB-72700"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01204.java b/OWASP DATASET CLEANED/BenchmarkTest01204.java deleted file mode 100644 index f386d258d33be5a2e03d038946f6f61c16366b7c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01204.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01204") -public class BenchmarkTest01204 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01204"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a40584 = param; // assign - StringBuilder b40584 = new StringBuilder(a40584); // stick in stringbuilder - b40584.append(" SafeStuff"); // append some safe content - b40584.replace( - b40584.length() - "Chars".length(), - b40584.length(), - "Chars"); // replace some of the end content - java.util.HashMap map40584 = new java.util.HashMap(); - map40584.put("key40584", b40584.toString()); // put in a collection - String c40584 = (String) map40584.get("key40584"); // get it back out - String d40584 = c40584.substring(0, c40584.length() - 1); // extract most of it - String e40584 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d40584.getBytes()))); // B64 encode and decode it - String f40584 = e40584.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f40584); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01205.java b/OWASP DATASET CLEANED/BenchmarkTest01205.java deleted file mode 100644 index 712a484aadf4780c814d7b56d800f52418d94014..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01205.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01205") -public class BenchmarkTest01205 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01205"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01206.java b/OWASP DATASET CLEANED/BenchmarkTest01206.java deleted file mode 100644 index f6ea3b71f00b49c5fc84588b7a8fea60091fe1e8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01206.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01206") -public class BenchmarkTest01206 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01206"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz14623 = new StringBuilder(param); - bar = - sbxyz14623 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01207.java b/OWASP DATASET CLEANED/BenchmarkTest01207.java deleted file mode 100644 index cd136f6d13977eb3a76e2f7a204176769ebb966e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01207.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01207") -public class BenchmarkTest01207 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01207"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map95902 = new java.util.HashMap(); - map95902.put("keyA-95902", "a_Value"); // put some stuff in the collection - map95902.put("keyB-95902", param); // put it in a collection - map95902.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map95902.get("keyB-95902"); // get it back out - bar = (String) map95902.get("keyA-95902"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01208.java b/OWASP DATASET CLEANED/BenchmarkTest01208.java deleted file mode 100644 index ec6c59f2643fe98e3862bf14a092732844b1a6c2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01208.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01208") -public class BenchmarkTest01208 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01208"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01209.java b/OWASP DATASET CLEANED/BenchmarkTest01209.java deleted file mode 100644 index ec84cdcafe65b66ddfaef896ff724cbe12d149f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01209.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01209") -public class BenchmarkTest01209 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01209"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01210.java b/OWASP DATASET CLEANED/BenchmarkTest01210.java deleted file mode 100644 index 37470a27d40e282e1727351ca3ef4c03730c339d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01210.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01210") -public class BenchmarkTest01210 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01210"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map86576 = new java.util.HashMap(); - map86576.put("keyA-86576", "a-Value"); // put some stuff in the collection - map86576.put("keyB-86576", param); // put it in a collection - map86576.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map86576.get("keyB-86576"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01211.java b/OWASP DATASET CLEANED/BenchmarkTest01211.java deleted file mode 100644 index a20772cf94273b6d18a0bbba74cd152556b515a3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01211.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01211") -public class BenchmarkTest01211 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01211"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01212.java b/OWASP DATASET CLEANED/BenchmarkTest01212.java deleted file mode 100644 index 00f97fa3b01100f9c020b1833c22a5c9d29524b7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01212.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01212") -public class BenchmarkTest01212 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01212"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new int[] {1, 2}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01213.java b/OWASP DATASET CLEANED/BenchmarkTest01213.java deleted file mode 100644 index 408861e5e6fea6b74f0ee4f457bf1b51c98a2497..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01213.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01213") -public class BenchmarkTest01213 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01213"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01214.java b/OWASP DATASET CLEANED/BenchmarkTest01214.java deleted file mode 100644 index 8750d62af5280336be34f41f7beddd3990579380..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01214.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01214") -public class BenchmarkTest01214 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01214"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01215.java b/OWASP DATASET CLEANED/BenchmarkTest01215.java deleted file mode 100644 index 2e39a83935b641b7041fe5343c2d5a7e2c87ef86..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01215.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01215") -public class BenchmarkTest01215 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01215"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01216.java b/OWASP DATASET CLEANED/BenchmarkTest01216.java deleted file mode 100644 index f9bbfe9d9d99a8792fa90aaf77218009817ed8e3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01216.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01216") -public class BenchmarkTest01216 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01216"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01217.java b/OWASP DATASET CLEANED/BenchmarkTest01217.java deleted file mode 100644 index 0e73e684f88a445883baa123875e13d8291346bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01217.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01217") -public class BenchmarkTest01217 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01217"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a89502 = param; // assign - StringBuilder b89502 = new StringBuilder(a89502); // stick in stringbuilder - b89502.append(" SafeStuff"); // append some safe content - b89502.replace( - b89502.length() - "Chars".length(), - b89502.length(), - "Chars"); // replace some of the end content - java.util.HashMap map89502 = new java.util.HashMap(); - map89502.put("key89502", b89502.toString()); // put in a collection - String c89502 = (String) map89502.get("key89502"); // get it back out - String d89502 = c89502.substring(0, c89502.length() - 1); // extract most of it - String e89502 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d89502.getBytes()))); // B64 encode and decode it - String f89502 = e89502.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g89502 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g89502); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01218.java b/OWASP DATASET CLEANED/BenchmarkTest01218.java deleted file mode 100644 index 81c5ad2ba3a91324c9b1ab834d2530939a43a8bc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01218.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01218") -public class BenchmarkTest01218 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01218"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01219.java b/OWASP DATASET CLEANED/BenchmarkTest01219.java deleted file mode 100644 index 18ba13eb338cf66320984a8b93bfaf56d6cc10d8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01219.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01219") -public class BenchmarkTest01219 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01219"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map23263 = new java.util.HashMap(); - map23263.put("keyA-23263", "a_Value"); // put some stuff in the collection - map23263.put("keyB-23263", param); // put it in a collection - map23263.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map23263.get("keyB-23263"); // get it back out - bar = (String) map23263.get("keyA-23263"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01220.java b/OWASP DATASET CLEANED/BenchmarkTest01220.java deleted file mode 100644 index adad23ef0c0335cd6b5b921ad3eeb4f413a6fc34..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01220.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01220") -public class BenchmarkTest01220 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01220"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01221.java b/OWASP DATASET CLEANED/BenchmarkTest01221.java deleted file mode 100644 index ab465982f457b48b8670ccc3001f9e0e96778a8e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01221.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01221") -public class BenchmarkTest01221 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01221"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01222.java b/OWASP DATASET CLEANED/BenchmarkTest01222.java deleted file mode 100644 index 6455a87a00822f56ade568b9338441b115578be3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01222.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01222") -public class BenchmarkTest01222 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01222"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map25738 = new java.util.HashMap(); - map25738.put("keyA-25738", "a-Value"); // put some stuff in the collection - map25738.put("keyB-25738", param); // put it in a collection - map25738.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map25738.get("keyB-25738"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01223.java b/OWASP DATASET CLEANED/BenchmarkTest01223.java deleted file mode 100644 index 91bca7d374b0941468ddee36f217c5a50a4da267..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01223.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01223") -public class BenchmarkTest01223 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01223"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01224.java b/OWASP DATASET CLEANED/BenchmarkTest01224.java deleted file mode 100644 index d03191227d57c8edc755352ba4f04b29db17a0c2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01224.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01224") -public class BenchmarkTest01224 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01224"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01225.java b/OWASP DATASET CLEANED/BenchmarkTest01225.java deleted file mode 100644 index a44cbbe5e29783439c02d8579951e508d68d9370..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01225.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01225") -public class BenchmarkTest01225 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest01225"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01226.java b/OWASP DATASET CLEANED/BenchmarkTest01226.java deleted file mode 100644 index e0948f5030872782f958eed369675e84e889c199..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01226.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01226") -public class BenchmarkTest01226 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01226"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01227.java b/OWASP DATASET CLEANED/BenchmarkTest01227.java deleted file mode 100644 index 9dd8530ed2a235a6ac8c2251c05c32173db4a8b9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01227.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01227") -public class BenchmarkTest01227 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01227"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz39213 = new StringBuilder(param); - bar = - sbxyz39213 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01228.java b/OWASP DATASET CLEANED/BenchmarkTest01228.java deleted file mode 100644 index b5c4eb89cf11b059b7bd993d9e3ce803c88b1f6e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01228.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01228") -public class BenchmarkTest01228 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01228"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01229.java b/OWASP DATASET CLEANED/BenchmarkTest01229.java deleted file mode 100644 index b786ad062f189aeef6c8c70b6ec05233f0ca415b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01229.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01229") -public class BenchmarkTest01229 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01229"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01230.java b/OWASP DATASET CLEANED/BenchmarkTest01230.java deleted file mode 100644 index aa88ecca16eda21e0fcede2a080402a563080aae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01230.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01230") -public class BenchmarkTest01230 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01230"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz45958 = new StringBuilder(param); - String bar = sbxyz45958.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01231.java b/OWASP DATASET CLEANED/BenchmarkTest01231.java deleted file mode 100644 index 2a1893a8f4e4dc4efe86561b2aeaeae0c6b03f83..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01231.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01231") -public class BenchmarkTest01231 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01231"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map35717 = new java.util.HashMap(); - map35717.put("keyA-35717", "a-Value"); // put some stuff in the collection - map35717.put("keyB-35717", param); // put it in a collection - map35717.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map35717.get("keyB-35717"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01232.java b/OWASP DATASET CLEANED/BenchmarkTest01232.java deleted file mode 100644 index f78d3128fda53ff40ff09cf38d71d95fcce61a81..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01232.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01232") -public class BenchmarkTest01232 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01232"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01233.java b/OWASP DATASET CLEANED/BenchmarkTest01233.java deleted file mode 100644 index 3f7c67eaebc68c8010bd9463efa1bda84a0c3efc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01233.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01233") -public class BenchmarkTest01233 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01233"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01234.java b/OWASP DATASET CLEANED/BenchmarkTest01234.java deleted file mode 100644 index ee77bafec09c36372c72393522e3e7ea81018938..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01234.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01234") -public class BenchmarkTest01234 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01234"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01235.java b/OWASP DATASET CLEANED/BenchmarkTest01235.java deleted file mode 100644 index 68d4d76bc4c2afc19b9f675cd928611bbf5296d7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01235.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01235") -public class BenchmarkTest01235 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01235"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map13886 = new java.util.HashMap(); - map13886.put("keyA-13886", "a-Value"); // put some stuff in the collection - map13886.put("keyB-13886", param); // put it in a collection - map13886.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map13886.get("keyB-13886"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01236.java b/OWASP DATASET CLEANED/BenchmarkTest01236.java deleted file mode 100644 index d120bf48fe57ec4dc21fca976eeb0f5bdaed0b25..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01236.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01236") -public class BenchmarkTest01236 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01236"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01237.java b/OWASP DATASET CLEANED/BenchmarkTest01237.java deleted file mode 100644 index 93447eb21d876c6e5bbcd198ae79d83e119c8685..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01237.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01237") -public class BenchmarkTest01237 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01237"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01238.java b/OWASP DATASET CLEANED/BenchmarkTest01238.java deleted file mode 100644 index be77a285efb5dddc5077346cc3fc07e421e87353..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01238.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01238") -public class BenchmarkTest01238 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01238"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01239.java b/OWASP DATASET CLEANED/BenchmarkTest01239.java deleted file mode 100644 index 4c92a0c4bb86bd48ed0a85cd4ea16381777ad9a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01239.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01239") -public class BenchmarkTest01239 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01239"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01240.java b/OWASP DATASET CLEANED/BenchmarkTest01240.java deleted file mode 100644 index ed44fadc1bfd6070c194bf6cb70fa19b6753da41..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01240.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01240") -public class BenchmarkTest01240 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01240"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01241.java b/OWASP DATASET CLEANED/BenchmarkTest01241.java deleted file mode 100644 index 2ff939b3344a881c91787c75ef7b867c744bdd85..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01241.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01241") -public class BenchmarkTest01241 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01241"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01242.java b/OWASP DATASET CLEANED/BenchmarkTest01242.java deleted file mode 100644 index 9ff6d4ec9ef2c788a10b83c649afa334f4fa510b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01242.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01242") -public class BenchmarkTest01242 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01242"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01243.java b/OWASP DATASET CLEANED/BenchmarkTest01243.java deleted file mode 100644 index 0ba48af860c8d9051fd0eaee4a2a3d316c03604c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01243.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01243") -public class BenchmarkTest01243 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01243"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01244.java b/OWASP DATASET CLEANED/BenchmarkTest01244.java deleted file mode 100644 index 19ce0543dd318aef65783b48912934c910023687..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01244.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01244") -public class BenchmarkTest01244 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01244"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01245.java b/OWASP DATASET CLEANED/BenchmarkTest01245.java deleted file mode 100644 index f032687ea826340eb97794f832afd68dddd0403e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01245.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01245") -public class BenchmarkTest01245 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01245"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01246.java b/OWASP DATASET CLEANED/BenchmarkTest01246.java deleted file mode 100644 index f5d13eda2d94daa04ca27b9f7e5bd803592661cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01246.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01246") -public class BenchmarkTest01246 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01246"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01247.java b/OWASP DATASET CLEANED/BenchmarkTest01247.java deleted file mode 100644 index d319bd87543c0a6def896cfc3dc3c190918564cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01247.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01247") -public class BenchmarkTest01247 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01247"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01248.java b/OWASP DATASET CLEANED/BenchmarkTest01248.java deleted file mode 100644 index eb713a85ab4a61a125bdc8ae4e44c6d9534f2490..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01248.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01248") -public class BenchmarkTest01248 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01248"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01249.java b/OWASP DATASET CLEANED/BenchmarkTest01249.java deleted file mode 100644 index bd3f2cb2b70ce3cdc086d88ce333c3156fa02822..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01249.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01249") -public class BenchmarkTest01249 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01249"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01250.java b/OWASP DATASET CLEANED/BenchmarkTest01250.java deleted file mode 100644 index 1034a240c03095a7a9b19ec59e15507b3fa223af..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01250.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01250") -public class BenchmarkTest01250 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01250"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01251.java b/OWASP DATASET CLEANED/BenchmarkTest01251.java deleted file mode 100644 index d5646d3a191f3fba8ed6ca7972a459a30a4dfa02..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01251.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01251") -public class BenchmarkTest01251 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01251"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01252.java b/OWASP DATASET CLEANED/BenchmarkTest01252.java deleted file mode 100644 index 8516f1f1d12a881f4c5ed910f56a53f267cfeab8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01252.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01252") -public class BenchmarkTest01252 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01252"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01253.java b/OWASP DATASET CLEANED/BenchmarkTest01253.java deleted file mode 100644 index 2535f4e42f8c1b64752e3cf4cad9a7863c1019df..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01253.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01253") -public class BenchmarkTest01253 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01253"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map15481 = new java.util.HashMap(); - map15481.put("keyA-15481", "a-Value"); // put some stuff in the collection - map15481.put("keyB-15481", param); // put it in a collection - map15481.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map15481.get("keyB-15481"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01254.java b/OWASP DATASET CLEANED/BenchmarkTest01254.java deleted file mode 100644 index 53d3591ea9b6f268a67220475901e94cc21f4255..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01254.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01254") -public class BenchmarkTest01254 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01254"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a23874 = param; // assign - StringBuilder b23874 = new StringBuilder(a23874); // stick in stringbuilder - b23874.append(" SafeStuff"); // append some safe content - b23874.replace( - b23874.length() - "Chars".length(), - b23874.length(), - "Chars"); // replace some of the end content - java.util.HashMap map23874 = new java.util.HashMap(); - map23874.put("key23874", b23874.toString()); // put in a collection - String c23874 = (String) map23874.get("key23874"); // get it back out - String d23874 = c23874.substring(0, c23874.length() - 1); // extract most of it - String e23874 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d23874.getBytes()))); // B64 encode and decode it - String f23874 = e23874.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f23874); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01255.java b/OWASP DATASET CLEANED/BenchmarkTest01255.java deleted file mode 100644 index cb27a121dfd56c99a960e17433892237b6089923..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01255.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01255") -public class BenchmarkTest01255 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01255"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01256.java b/OWASP DATASET CLEANED/BenchmarkTest01256.java deleted file mode 100644 index c87b7124676c9d0d4eb738c0a83b8a1e539e7a9d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01256.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01256") -public class BenchmarkTest01256 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01256"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01257.java b/OWASP DATASET CLEANED/BenchmarkTest01257.java deleted file mode 100644 index 2a4f80410a2fbf84159b5fac2e7082822afbcacf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01257.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01257") -public class BenchmarkTest01257 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01257"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01258.java b/OWASP DATASET CLEANED/BenchmarkTest01258.java deleted file mode 100644 index 9aaac3b2199cafb1167af8b41dd7ac46fe874c64..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01258.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01258") -public class BenchmarkTest01258 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01258"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01259.java b/OWASP DATASET CLEANED/BenchmarkTest01259.java deleted file mode 100644 index 4b3b34282d3d56582c9ce540a0fbf59f0f534adf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01259.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01259") -public class BenchmarkTest01259 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01259"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map26093 = new java.util.HashMap(); - map26093.put("keyA-26093", "a-Value"); // put some stuff in the collection - map26093.put("keyB-26093", param); // put it in a collection - map26093.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map26093.get("keyB-26093"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01260.java b/OWASP DATASET CLEANED/BenchmarkTest01260.java deleted file mode 100644 index 6c4e54339028351f3df3f2d241f8bb94c5733dd4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01260.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01260") -public class BenchmarkTest01260 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01260"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01261.java b/OWASP DATASET CLEANED/BenchmarkTest01261.java deleted file mode 100644 index 935e3dc8bb34fdb3baf5fa2202b48f1b02a4e426..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01261.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01261") -public class BenchmarkTest01261 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01261"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a34194 = param; // assign - StringBuilder b34194 = new StringBuilder(a34194); // stick in stringbuilder - b34194.append(" SafeStuff"); // append some safe content - b34194.replace( - b34194.length() - "Chars".length(), - b34194.length(), - "Chars"); // replace some of the end content - java.util.HashMap map34194 = new java.util.HashMap(); - map34194.put("key34194", b34194.toString()); // put in a collection - String c34194 = (String) map34194.get("key34194"); // get it back out - String d34194 = c34194.substring(0, c34194.length() - 1); // extract most of it - String e34194 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d34194.getBytes()))); // B64 encode and decode it - String f34194 = e34194.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f34194); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01262.java b/OWASP DATASET CLEANED/BenchmarkTest01262.java deleted file mode 100644 index deea4c37206abae3968209014e7c1fef4bc2e668..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01262.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01262") -public class BenchmarkTest01262 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01262"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01263.java b/OWASP DATASET CLEANED/BenchmarkTest01263.java deleted file mode 100644 index dfc717c05ef100227a3cf0eb40d7c48542ce5ab6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01263.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01263") -public class BenchmarkTest01263 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01263"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01264.java b/OWASP DATASET CLEANED/BenchmarkTest01264.java deleted file mode 100644 index 5118d4eb3542d6396dafdcf856d2fdae60f5e430..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01264.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01264") -public class BenchmarkTest01264 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01264"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01265.java b/OWASP DATASET CLEANED/BenchmarkTest01265.java deleted file mode 100644 index 68c07666f250dd4a6d4eb730e154d825577423bc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01265.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01265") -public class BenchmarkTest01265 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01265"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01266.java b/OWASP DATASET CLEANED/BenchmarkTest01266.java deleted file mode 100644 index 4b8d18249f46c412ff5e4ca565a469a4f66ad2b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01266.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01266") -public class BenchmarkTest01266 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01266"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01267.java b/OWASP DATASET CLEANED/BenchmarkTest01267.java deleted file mode 100644 index 947895c739ad8425d7ad42c399e562438626fcf0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01267.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01267") -public class BenchmarkTest01267 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01267"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map53210 = new java.util.HashMap(); - map53210.put("keyA-53210", "a-Value"); // put some stuff in the collection - map53210.put("keyB-53210", param); // put it in a collection - map53210.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map53210.get("keyB-53210"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01268.java b/OWASP DATASET CLEANED/BenchmarkTest01268.java deleted file mode 100644 index 77f7350fd0b209752cbeb12137bfd00f302b61a2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01268.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01268") -public class BenchmarkTest01268 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01268"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a92384 = param; // assign - StringBuilder b92384 = new StringBuilder(a92384); // stick in stringbuilder - b92384.append(" SafeStuff"); // append some safe content - b92384.replace( - b92384.length() - "Chars".length(), - b92384.length(), - "Chars"); // replace some of the end content - java.util.HashMap map92384 = new java.util.HashMap(); - map92384.put("key92384", b92384.toString()); // put in a collection - String c92384 = (String) map92384.get("key92384"); // get it back out - String d92384 = c92384.substring(0, c92384.length() - 1); // extract most of it - String e92384 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d92384.getBytes()))); // B64 encode and decode it - String f92384 = e92384.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f92384); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01269.java b/OWASP DATASET CLEANED/BenchmarkTest01269.java deleted file mode 100644 index b5e4e746b001d79e22b19fdbdfb027cf8535bed9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01269.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01269") -public class BenchmarkTest01269 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01269"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01270.java b/OWASP DATASET CLEANED/BenchmarkTest01270.java deleted file mode 100644 index fb3f0246471abfdc6fd5e343e484194244b6d2fe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01270.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01270") -public class BenchmarkTest01270 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01270"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01271.java b/OWASP DATASET CLEANED/BenchmarkTest01271.java deleted file mode 100644 index 11a10cac74840d1752a284c9e5f24ba060e2b1d1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01271.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01271") -public class BenchmarkTest01271 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01271"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a4086 = param; // assign - StringBuilder b4086 = new StringBuilder(a4086); // stick in stringbuilder - b4086.append(" SafeStuff"); // append some safe content - b4086.replace( - b4086.length() - "Chars".length(), - b4086.length(), - "Chars"); // replace some of the end content - java.util.HashMap map4086 = new java.util.HashMap(); - map4086.put("key4086", b4086.toString()); // put in a collection - String c4086 = (String) map4086.get("key4086"); // get it back out - String d4086 = c4086.substring(0, c4086.length() - 1); // extract most of it - String e4086 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d4086.getBytes()))); // B64 encode and decode it - String f4086 = e4086.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g4086 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g4086); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01272.java b/OWASP DATASET CLEANED/BenchmarkTest01272.java deleted file mode 100644 index aa1f2043ee803197910d67de6de690f6c594bc09..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01272.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01272") -public class BenchmarkTest01272 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01272"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01273.java b/OWASP DATASET CLEANED/BenchmarkTest01273.java deleted file mode 100644 index 9675abc8e35b48912f6757b4dd68f34be11dd23b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01273.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01273") -public class BenchmarkTest01273 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01273"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01274.java b/OWASP DATASET CLEANED/BenchmarkTest01274.java deleted file mode 100644 index 2701368f79e641d32b5aaed722838bf2069f331c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01274.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01274") -public class BenchmarkTest01274 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01274"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01275.java b/OWASP DATASET CLEANED/BenchmarkTest01275.java deleted file mode 100644 index 36d888a94ee2726b5632aa9c7acbdcd1492c5282..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01275.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01275") -public class BenchmarkTest01275 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01275"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz27989 = new StringBuilder(param); - String bar = sbxyz27989.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01276.java b/OWASP DATASET CLEANED/BenchmarkTest01276.java deleted file mode 100644 index a204e6bd69c296b574b10c818e6757895a2bc246..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01276.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01276") -public class BenchmarkTest01276 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01276"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a83599 = param; // assign - StringBuilder b83599 = new StringBuilder(a83599); // stick in stringbuilder - b83599.append(" SafeStuff"); // append some safe content - b83599.replace( - b83599.length() - "Chars".length(), - b83599.length(), - "Chars"); // replace some of the end content - java.util.HashMap map83599 = new java.util.HashMap(); - map83599.put("key83599", b83599.toString()); // put in a collection - String c83599 = (String) map83599.get("key83599"); // get it back out - String d83599 = c83599.substring(0, c83599.length() - 1); // extract most of it - String e83599 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d83599.getBytes()))); // B64 encode and decode it - String f83599 = e83599.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f83599); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01277.java b/OWASP DATASET CLEANED/BenchmarkTest01277.java deleted file mode 100644 index 93950e7f42a2e1456f8eacb35e95c7babe72199e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01277.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01277") -public class BenchmarkTest01277 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01277"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01278.java b/OWASP DATASET CLEANED/BenchmarkTest01278.java deleted file mode 100644 index 02bc3ea0a0a2017cffbb173ca1837dbfd6c96083..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01278.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01278") -public class BenchmarkTest01278 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01278"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01279.java b/OWASP DATASET CLEANED/BenchmarkTest01279.java deleted file mode 100644 index 48f709a2dd49f8b47ed1e8dc8aa671ead2a9f07e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01279.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01279") -public class BenchmarkTest01279 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01279"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01280.java b/OWASP DATASET CLEANED/BenchmarkTest01280.java deleted file mode 100644 index 4d52db5740ae6108c8a1d82401dd4a1063c88a24..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01280.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01280") -public class BenchmarkTest01280 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01280"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01281.java b/OWASP DATASET CLEANED/BenchmarkTest01281.java deleted file mode 100644 index d410447d980b838cb9d8d85fcdeed80f15682d48..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01281.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01281") -public class BenchmarkTest01281 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01281"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01282.java b/OWASP DATASET CLEANED/BenchmarkTest01282.java deleted file mode 100644 index 54b5a00a2c546ac969a5652e4654e24dcfc9853c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01282.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01282") -public class BenchmarkTest01282 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01282"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01283.java b/OWASP DATASET CLEANED/BenchmarkTest01283.java deleted file mode 100644 index 5e433deddf08d3eddd57dd20586439d0f131237b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01283.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01283") -public class BenchmarkTest01283 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01283"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01284.java b/OWASP DATASET CLEANED/BenchmarkTest01284.java deleted file mode 100644 index e75d8ff681807e1421f775e9f19a7cb1eb1419ea..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01284.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01284") -public class BenchmarkTest01284 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01284"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01285.java b/OWASP DATASET CLEANED/BenchmarkTest01285.java deleted file mode 100644 index 74bf8bfc72a4d929cfaf5466dc855c0797b2df51..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01285.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01285") -public class BenchmarkTest01285 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01285"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01286.java b/OWASP DATASET CLEANED/BenchmarkTest01286.java deleted file mode 100644 index 91d3dbad0c6bcc412dd7d804c1214f7d2647fc17..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01286.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01286") -public class BenchmarkTest01286 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01286"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01287.java b/OWASP DATASET CLEANED/BenchmarkTest01287.java deleted file mode 100644 index 4cb67e3cd9e561897e206f4e73607fa997889067..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01287.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01287") -public class BenchmarkTest01287 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01287"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01288.java b/OWASP DATASET CLEANED/BenchmarkTest01288.java deleted file mode 100644 index 5e131ae30a0a72aa44bf6e261f64bcffab38f770..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01288.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01288") -public class BenchmarkTest01288 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01288"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map58555 = new java.util.HashMap(); - map58555.put("keyA-58555", "a-Value"); // put some stuff in the collection - map58555.put("keyB-58555", param); // put it in a collection - map58555.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map58555.get("keyB-58555"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01289.java b/OWASP DATASET CLEANED/BenchmarkTest01289.java deleted file mode 100644 index 4b11dae8ba0974d52a895c896f1464d6008fb532..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01289.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01289") -public class BenchmarkTest01289 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01289"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01290.java b/OWASP DATASET CLEANED/BenchmarkTest01290.java deleted file mode 100644 index ba1ee728989a36a331dd070b8c30d266985e5f36..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01290.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01290") -public class BenchmarkTest01290 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01290"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01291.java b/OWASP DATASET CLEANED/BenchmarkTest01291.java deleted file mode 100644 index d7623494466ab81485e800c46acc51ee2972c5fb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01291.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01291") -public class BenchmarkTest01291 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01291"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz42950 = new StringBuilder(param); - bar = - sbxyz42950 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01292.java b/OWASP DATASET CLEANED/BenchmarkTest01292.java deleted file mode 100644 index 8cb40cd1fbb16b6bdec5958462251cfc21b6e8ad..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01292.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01292") -public class BenchmarkTest01292 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01292"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01293.java b/OWASP DATASET CLEANED/BenchmarkTest01293.java deleted file mode 100644 index b3e77419a45c0d64560cd3a3890eba58f67b28fa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01293.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01293") -public class BenchmarkTest01293 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01293"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01294.java b/OWASP DATASET CLEANED/BenchmarkTest01294.java deleted file mode 100644 index 47cede1b9bbeb830d7bd7fa749a9eb8179472e20..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01294.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01294") -public class BenchmarkTest01294 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01294"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01295.java b/OWASP DATASET CLEANED/BenchmarkTest01295.java deleted file mode 100644 index ddf8ebe411a8df74fda7692f638843b9e96be4e5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01295.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-02/BenchmarkTest01295") -public class BenchmarkTest01295 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01295"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a22205 = param; // assign - StringBuilder b22205 = new StringBuilder(a22205); // stick in stringbuilder - b22205.append(" SafeStuff"); // append some safe content - b22205.replace( - b22205.length() - "Chars".length(), - b22205.length(), - "Chars"); // replace some of the end content - java.util.HashMap map22205 = new java.util.HashMap(); - map22205.put("key22205", b22205.toString()); // put in a collection - String c22205 = (String) map22205.get("key22205"); // get it back out - String d22205 = c22205.substring(0, c22205.length() - 1); // extract most of it - String e22205 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d22205.getBytes()))); // B64 encode and decode it - String f22205 = e22205.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g22205 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g22205); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01296.java b/OWASP DATASET CLEANED/BenchmarkTest01296.java deleted file mode 100644 index 8ac9be45f75fc4f6dbc1188590b601472fa94a18..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01296.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01296") -public class BenchmarkTest01296 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01296"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01297.java b/OWASP DATASET CLEANED/BenchmarkTest01297.java deleted file mode 100644 index 729e43e8ae0730e6ca43bcc5021015d04236515a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01297.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01297") -public class BenchmarkTest01297 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01297"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01298.java b/OWASP DATASET CLEANED/BenchmarkTest01298.java deleted file mode 100644 index 9653641e492fcff0aef5ad50921596b0c914929f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01298.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01298") -public class BenchmarkTest01298 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01298"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01299.java b/OWASP DATASET CLEANED/BenchmarkTest01299.java deleted file mode 100644 index d2b2bb9955a8a618b2a7125da0d0ff776d2810ea..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01299.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01299") -public class BenchmarkTest01299 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01299"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01300.java b/OWASP DATASET CLEANED/BenchmarkTest01300.java deleted file mode 100644 index 03ad0b4aee23c6b76016ef1d7667010790b65b3d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01300.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01300") -public class BenchmarkTest01300 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01300"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01301.java b/OWASP DATASET CLEANED/BenchmarkTest01301.java deleted file mode 100644 index 42743c2a2db953f1c56468bc816b2bf4010d46fd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01301.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01301") -public class BenchmarkTest01301 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01301"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a11416 = param; // assign - StringBuilder b11416 = new StringBuilder(a11416); // stick in stringbuilder - b11416.append(" SafeStuff"); // append some safe content - b11416.replace( - b11416.length() - "Chars".length(), - b11416.length(), - "Chars"); // replace some of the end content - java.util.HashMap map11416 = new java.util.HashMap(); - map11416.put("key11416", b11416.toString()); // put in a collection - String c11416 = (String) map11416.get("key11416"); // get it back out - String d11416 = c11416.substring(0, c11416.length() - 1); // extract most of it - String e11416 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d11416.getBytes()))); // B64 encode and decode it - String f11416 = e11416.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g11416 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g11416); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01302.java b/OWASP DATASET CLEANED/BenchmarkTest01302.java deleted file mode 100644 index abeba745c07a3ede54b2124bf15dcb459fa175e5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01302.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01302") -public class BenchmarkTest01302 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01302"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01303.java b/OWASP DATASET CLEANED/BenchmarkTest01303.java deleted file mode 100644 index a9097e0ce171d93fff35c45270763df1dc947c93..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01303.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01303") -public class BenchmarkTest01303 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01303"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01304.java b/OWASP DATASET CLEANED/BenchmarkTest01304.java deleted file mode 100644 index 81df696a9136da61bbde406993ed43962a24dc51..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01304.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01304") -public class BenchmarkTest01304 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01304"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01305.java b/OWASP DATASET CLEANED/BenchmarkTest01305.java deleted file mode 100644 index 1033c2afa21f77197815fe5eb8254cb462b681f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01305.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01305") -public class BenchmarkTest01305 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01305"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new int[] {1, 2}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01306.java b/OWASP DATASET CLEANED/BenchmarkTest01306.java deleted file mode 100644 index 5ccf127dea60fa7cfe6023d82a2ea828eb051ba1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01306.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01306") -public class BenchmarkTest01306 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01306"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01307.java b/OWASP DATASET CLEANED/BenchmarkTest01307.java deleted file mode 100644 index 9c6785d3baadcaff60469f99ec6e5479e914062b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01307.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01307") -public class BenchmarkTest01307 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01307"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01308.java b/OWASP DATASET CLEANED/BenchmarkTest01308.java deleted file mode 100644 index 311a4157952aecc2b138c001b98b1c7ce3f3609d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01308.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01308") -public class BenchmarkTest01308 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01308"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01309.java b/OWASP DATASET CLEANED/BenchmarkTest01309.java deleted file mode 100644 index 95128e162b9dce0257a9b6e1aab9cf354bee5182..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01309.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01309") -public class BenchmarkTest01309 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01309"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a9334 = param; // assign - StringBuilder b9334 = new StringBuilder(a9334); // stick in stringbuilder - b9334.append(" SafeStuff"); // append some safe content - b9334.replace( - b9334.length() - "Chars".length(), - b9334.length(), - "Chars"); // replace some of the end content - java.util.HashMap map9334 = new java.util.HashMap(); - map9334.put("key9334", b9334.toString()); // put in a collection - String c9334 = (String) map9334.get("key9334"); // get it back out - String d9334 = c9334.substring(0, c9334.length() - 1); // extract most of it - String e9334 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d9334.getBytes()))); // B64 encode and decode it - String f9334 = e9334.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g9334 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g9334); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01310.java b/OWASP DATASET CLEANED/BenchmarkTest01310.java deleted file mode 100644 index c7ea9ab13c79e1894b8991e88124e509e4388c6d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01310.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01310") -public class BenchmarkTest01310 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01310"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01311.java b/OWASP DATASET CLEANED/BenchmarkTest01311.java deleted file mode 100644 index c0a9091848836d95b932817e54b48bf444f809d4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01311.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01311") -public class BenchmarkTest01311 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01311"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01312.java b/OWASP DATASET CLEANED/BenchmarkTest01312.java deleted file mode 100644 index b073504092cb1a23878473a3e35419af778de2c3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01312.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01312") -public class BenchmarkTest01312 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01312"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01313.java b/OWASP DATASET CLEANED/BenchmarkTest01313.java deleted file mode 100644 index a7960f6ce49b4870e0afd266f512a8b1fa688205..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01313.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01313") -public class BenchmarkTest01313 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01313"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01314.java b/OWASP DATASET CLEANED/BenchmarkTest01314.java deleted file mode 100644 index e3643925d03d58b48eff3a0c91c674c9fafa8e65..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01314.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01314") -public class BenchmarkTest01314 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01314"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01315.java b/OWASP DATASET CLEANED/BenchmarkTest01315.java deleted file mode 100644 index 9aa8acbc721772b3239a69491be8a542d57d7a7e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01315.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01315") -public class BenchmarkTest01315 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01315"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01316.java b/OWASP DATASET CLEANED/BenchmarkTest01316.java deleted file mode 100644 index a5d41de8ffc177d2999f69e0fcbccbb056235454..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01316.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01316") -public class BenchmarkTest01316 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest01316"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01317.java b/OWASP DATASET CLEANED/BenchmarkTest01317.java deleted file mode 100644 index a702e8a51ccfa75673766cd90142a76adf7ae3e9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01317.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01317") -public class BenchmarkTest01317 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01317"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01318.java b/OWASP DATASET CLEANED/BenchmarkTest01318.java deleted file mode 100644 index c08ff0ff36b90438c84e8c80dd6f27e41e01306f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01318.java +++ /dev/null @@ -1,184 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01318") -public class BenchmarkTest01318 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01318"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a66881 = param; // assign - StringBuilder b66881 = new StringBuilder(a66881); // stick in stringbuilder - b66881.append(" SafeStuff"); // append some safe content - b66881.replace( - b66881.length() - "Chars".length(), - b66881.length(), - "Chars"); // replace some of the end content - java.util.HashMap map66881 = new java.util.HashMap(); - map66881.put("key66881", b66881.toString()); // put in a collection - String c66881 = (String) map66881.get("key66881"); // get it back out - String d66881 = c66881.substring(0, c66881.length() - 1); // extract most of it - String e66881 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d66881.getBytes()))); // B64 encode and decode it - String f66881 = e66881.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g66881 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g66881); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01319.java b/OWASP DATASET CLEANED/BenchmarkTest01319.java deleted file mode 100644 index 8ee13707f5c76b0c3e8bdae9bf1e16b91b5f796b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01319.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01319") -public class BenchmarkTest01319 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01319"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01320.java b/OWASP DATASET CLEANED/BenchmarkTest01320.java deleted file mode 100644 index ec45ddd805bbdff69dec073b54a71c2f57477014..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01320.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01320") -public class BenchmarkTest01320 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01320"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01321.java b/OWASP DATASET CLEANED/BenchmarkTest01321.java deleted file mode 100644 index ea041de408f0548c0bd2a9a0ed3673e44e9c5d5d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01321.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01321") -public class BenchmarkTest01321 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01321"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01322.java b/OWASP DATASET CLEANED/BenchmarkTest01322.java deleted file mode 100644 index 700bbc4de78c80c203534e038dc5309dd8489870..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01322.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01322") -public class BenchmarkTest01322 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01322"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01323.java b/OWASP DATASET CLEANED/BenchmarkTest01323.java deleted file mode 100644 index f206c5bf537090205d8ae6be22a8359737f8ea93..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01323.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01323") -public class BenchmarkTest01323 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01323"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map1195 = new java.util.HashMap(); - map1195.put("keyA-1195", "a-Value"); // put some stuff in the collection - map1195.put("keyB-1195", param); // put it in a collection - map1195.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map1195.get("keyB-1195"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01324.java b/OWASP DATASET CLEANED/BenchmarkTest01324.java deleted file mode 100644 index 697d1a60fb76d50308d4df868f56dadf399c0f0d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01324.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01324") -public class BenchmarkTest01324 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01324"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01325.java b/OWASP DATASET CLEANED/BenchmarkTest01325.java deleted file mode 100644 index 2de5cf65b2ff78b060e7f928f2c2735a96c31280..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01325.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01325") -public class BenchmarkTest01325 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01325"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map39183 = new java.util.HashMap(); - map39183.put("keyA-39183", "a_Value"); // put some stuff in the collection - map39183.put("keyB-39183", param); // put it in a collection - map39183.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map39183.get("keyB-39183"); // get it back out - bar = (String) map39183.get("keyA-39183"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01326.java b/OWASP DATASET CLEANED/BenchmarkTest01326.java deleted file mode 100644 index 5190bcb65c7778a7aa7d1099f98075b909007866..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01326.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01326") -public class BenchmarkTest01326 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01326"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01327.java b/OWASP DATASET CLEANED/BenchmarkTest01327.java deleted file mode 100644 index 8190031458fba31ccfe40bda42c4917542775cac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01327.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01327") -public class BenchmarkTest01327 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01327"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map41804 = new java.util.HashMap(); - map41804.put("keyA-41804", "a_Value"); // put some stuff in the collection - map41804.put("keyB-41804", param); // put it in a collection - map41804.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map41804.get("keyB-41804"); // get it back out - bar = (String) map41804.get("keyA-41804"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01328.java b/OWASP DATASET CLEANED/BenchmarkTest01328.java deleted file mode 100644 index bfdf8f2b03844400bea161c5316fca34ccf0ab89..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01328.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01328") -public class BenchmarkTest01328 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01328"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a17973 = param; // assign - StringBuilder b17973 = new StringBuilder(a17973); // stick in stringbuilder - b17973.append(" SafeStuff"); // append some safe content - b17973.replace( - b17973.length() - "Chars".length(), - b17973.length(), - "Chars"); // replace some of the end content - java.util.HashMap map17973 = new java.util.HashMap(); - map17973.put("key17973", b17973.toString()); // put in a collection - String c17973 = (String) map17973.get("key17973"); // get it back out - String d17973 = c17973.substring(0, c17973.length() - 1); // extract most of it - String e17973 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d17973.getBytes()))); // B64 encode and decode it - String f17973 = e17973.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g17973 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g17973); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01329.java b/OWASP DATASET CLEANED/BenchmarkTest01329.java deleted file mode 100644 index a527770422c35f4f220beff1c35dceb005bb2570..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01329.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01329") -public class BenchmarkTest01329 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01329"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01330.java b/OWASP DATASET CLEANED/BenchmarkTest01330.java deleted file mode 100644 index f0f654f09e8e0d91b441b40b4512d605b53c6e2d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01330.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01330") -public class BenchmarkTest01330 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01330"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01331.java b/OWASP DATASET CLEANED/BenchmarkTest01331.java deleted file mode 100644 index af3d4642b9e5ecba0b98313bd6aa5f5574bcc3c4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01331.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01331") -public class BenchmarkTest01331 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01331"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01332.java b/OWASP DATASET CLEANED/BenchmarkTest01332.java deleted file mode 100644 index 9efccdc3ad99d48135090dcbe6323dd3656f7fe0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01332.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01332") -public class BenchmarkTest01332 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01332"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz43527 = new StringBuilder(param); - String bar = sbxyz43527.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01333.java b/OWASP DATASET CLEANED/BenchmarkTest01333.java deleted file mode 100644 index fe642a065bbd6bbfb7e8951402b30706e6305e13..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01333.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01333") -public class BenchmarkTest01333 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01333"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01334.java b/OWASP DATASET CLEANED/BenchmarkTest01334.java deleted file mode 100644 index 7afdade06ab08961e1e225b0d9a1046eeffe4ef4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01334.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01334") -public class BenchmarkTest01334 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01334"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01335.java b/OWASP DATASET CLEANED/BenchmarkTest01335.java deleted file mode 100644 index 74311b0c978f9d0f1283186ec98e8fb49dc1c872..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01335.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01335") -public class BenchmarkTest01335 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01335"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map45376 = new java.util.HashMap(); - map45376.put("keyA-45376", "a-Value"); // put some stuff in the collection - map45376.put("keyB-45376", param); // put it in a collection - map45376.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map45376.get("keyB-45376"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01336.java b/OWASP DATASET CLEANED/BenchmarkTest01336.java deleted file mode 100644 index 5bd1621a1e8e9b88a6f97e52921f6d72275c6b30..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01336.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01336") -public class BenchmarkTest01336 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01336"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01337.java b/OWASP DATASET CLEANED/BenchmarkTest01337.java deleted file mode 100644 index 0d70fd38974fdeff9cbad52381c131897c46dbf4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01337.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01337") -public class BenchmarkTest01337 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01337"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz24804 = new StringBuilder(param); - String bar = sbxyz24804.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01338.java b/OWASP DATASET CLEANED/BenchmarkTest01338.java deleted file mode 100644 index 19d39814a21c9eb7cf34bc78cc40c2aba1e9cf75..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01338.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01338") -public class BenchmarkTest01338 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01338"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01339.java b/OWASP DATASET CLEANED/BenchmarkTest01339.java deleted file mode 100644 index 0f667219fedc36ad2b048be5a5c6a15ab8fb28de..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01339.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01339") -public class BenchmarkTest01339 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01339"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01340.java b/OWASP DATASET CLEANED/BenchmarkTest01340.java deleted file mode 100644 index 61fbd1e3007864c043acdbab6d7cf0ad34292bb2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01340.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01340") -public class BenchmarkTest01340 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01340"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map36950 = new java.util.HashMap(); - map36950.put("keyA-36950", "a_Value"); // put some stuff in the collection - map36950.put("keyB-36950", param); // put it in a collection - map36950.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map36950.get("keyB-36950"); // get it back out - bar = (String) map36950.get("keyA-36950"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01341.java b/OWASP DATASET CLEANED/BenchmarkTest01341.java deleted file mode 100644 index b11bac2b12004716ca2fe7440fb6f8e762b89c64..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01341.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01341") -public class BenchmarkTest01341 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01341"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a41908 = param; // assign - StringBuilder b41908 = new StringBuilder(a41908); // stick in stringbuilder - b41908.append(" SafeStuff"); // append some safe content - b41908.replace( - b41908.length() - "Chars".length(), - b41908.length(), - "Chars"); // replace some of the end content - java.util.HashMap map41908 = new java.util.HashMap(); - map41908.put("key41908", b41908.toString()); // put in a collection - String c41908 = (String) map41908.get("key41908"); // get it back out - String d41908 = c41908.substring(0, c41908.length() - 1); // extract most of it - String e41908 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d41908.getBytes()))); // B64 encode and decode it - String f41908 = e41908.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g41908 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g41908); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01342.java b/OWASP DATASET CLEANED/BenchmarkTest01342.java deleted file mode 100644 index d53e4d30607cda0ceba963491bcd001ae59f58e2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01342.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01342") -public class BenchmarkTest01342 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01342"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01343.java b/OWASP DATASET CLEANED/BenchmarkTest01343.java deleted file mode 100644 index d8fc4b625b926e7bac294648d5464971264491a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01343.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01343") -public class BenchmarkTest01343 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01343"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01344.java b/OWASP DATASET CLEANED/BenchmarkTest01344.java deleted file mode 100644 index 9a10b73a798498310032c17d60560e83e4ca46cc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01344.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01344") -public class BenchmarkTest01344 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01344"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01345.java b/OWASP DATASET CLEANED/BenchmarkTest01345.java deleted file mode 100644 index f4a746dbebd5dafede451027754930d05f113c92..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01345.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01345") -public class BenchmarkTest01345 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01345"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01346.java b/OWASP DATASET CLEANED/BenchmarkTest01346.java deleted file mode 100644 index 9899bff329cc7946968e78824e6a7310a9622e6e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01346.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01346") -public class BenchmarkTest01346 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01346"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01347.java b/OWASP DATASET CLEANED/BenchmarkTest01347.java deleted file mode 100644 index 5408acb82c50e4d8dde640214cc046bb317b5b7d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01347.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01347") -public class BenchmarkTest01347 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01347"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a81561 = param; // assign - StringBuilder b81561 = new StringBuilder(a81561); // stick in stringbuilder - b81561.append(" SafeStuff"); // append some safe content - b81561.replace( - b81561.length() - "Chars".length(), - b81561.length(), - "Chars"); // replace some of the end content - java.util.HashMap map81561 = new java.util.HashMap(); - map81561.put("key81561", b81561.toString()); // put in a collection - String c81561 = (String) map81561.get("key81561"); // get it back out - String d81561 = c81561.substring(0, c81561.length() - 1); // extract most of it - String e81561 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d81561.getBytes()))); // B64 encode and decode it - String f81561 = e81561.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f81561); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01348.java b/OWASP DATASET CLEANED/BenchmarkTest01348.java deleted file mode 100644 index 529c09e773fbfdb7cfecf7c80416484e03d78b63..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01348.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01348") -public class BenchmarkTest01348 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01348"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01349.java b/OWASP DATASET CLEANED/BenchmarkTest01349.java deleted file mode 100644 index 95c550f70e35afa3e9f3ef39ac1c5575532e01b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01349.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01349") -public class BenchmarkTest01349 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01349"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz63030 = new StringBuilder(param); - String bar = sbxyz63030.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01350.java b/OWASP DATASET CLEANED/BenchmarkTest01350.java deleted file mode 100644 index 527911b5f90a10924b25ad9fd2b4e7e16f71a3f8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01350.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01350") -public class BenchmarkTest01350 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01350"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01351.java b/OWASP DATASET CLEANED/BenchmarkTest01351.java deleted file mode 100644 index 9b62d8477afce1e8ee9d41ca13bffa21a694efbe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01351.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01351") -public class BenchmarkTest01351 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01351"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01352.java b/OWASP DATASET CLEANED/BenchmarkTest01352.java deleted file mode 100644 index 5ccfcc39a26835dbd511665189d627a0afb6a5c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01352.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01352") -public class BenchmarkTest01352 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01352"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01353.java b/OWASP DATASET CLEANED/BenchmarkTest01353.java deleted file mode 100644 index f26dd5cf3f7eab2294943139a37ec6405eb510fa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01353.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01353") -public class BenchmarkTest01353 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01353"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01354.java b/OWASP DATASET CLEANED/BenchmarkTest01354.java deleted file mode 100644 index cf862110c00602df334e95fa39e8c9b4810da49d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01354.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01354") -public class BenchmarkTest01354 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01354"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01355.java b/OWASP DATASET CLEANED/BenchmarkTest01355.java deleted file mode 100644 index 0e84dde038014f746e769f69594b89ed142d01e9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01355.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01355") -public class BenchmarkTest01355 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01355"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01356.java b/OWASP DATASET CLEANED/BenchmarkTest01356.java deleted file mode 100644 index ab9779888deecc094d6e661584dd25cd6a4d96c7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01356.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01356") -public class BenchmarkTest01356 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01356"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01357.java b/OWASP DATASET CLEANED/BenchmarkTest01357.java deleted file mode 100644 index ab973f3d3811200172a739825cebba9702c4a6b1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01357.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01357") -public class BenchmarkTest01357 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01357"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01358.java b/OWASP DATASET CLEANED/BenchmarkTest01358.java deleted file mode 100644 index 794ffd96f7da5fbbabb4f90dbba40467e2d3e0b3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01358.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01358") -public class BenchmarkTest01358 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01358"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01359.java b/OWASP DATASET CLEANED/BenchmarkTest01359.java deleted file mode 100644 index b0321acbfe4757ccc7a3bfc56d182709bde92b83..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01359.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01359") -public class BenchmarkTest01359 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01359"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01360.java b/OWASP DATASET CLEANED/BenchmarkTest01360.java deleted file mode 100644 index 6ff5099a7cf6bbe03cb8e149550ebdb398832d66..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01360.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01360") -public class BenchmarkTest01360 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01360"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01361.java b/OWASP DATASET CLEANED/BenchmarkTest01361.java deleted file mode 100644 index ab7fc98fd3b1a148c15d8af790c0bc5a2f289971..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01361.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01361") -public class BenchmarkTest01361 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01361"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01362.java b/OWASP DATASET CLEANED/BenchmarkTest01362.java deleted file mode 100644 index 92da56d24be34e9d6ac271aae2791cef6c88cdb8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01362.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01362") -public class BenchmarkTest01362 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01362"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01363.java b/OWASP DATASET CLEANED/BenchmarkTest01363.java deleted file mode 100644 index 283542416fede86a019e2206f2247b86fc9debb9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01363.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01363") -public class BenchmarkTest01363 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01363"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01364.java b/OWASP DATASET CLEANED/BenchmarkTest01364.java deleted file mode 100644 index 8550d4407ef8d030bdcb89d8c052b3903dd07c81..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01364.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01364") -public class BenchmarkTest01364 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01364"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01365.java b/OWASP DATASET CLEANED/BenchmarkTest01365.java deleted file mode 100644 index d25b902fee3451d2ae6e8a4a98484fe8d9542260..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01365.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01365") -public class BenchmarkTest01365 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01365"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01366.java b/OWASP DATASET CLEANED/BenchmarkTest01366.java deleted file mode 100644 index fece7998e6e544f7ba7086ac149dd0ceb1ee103c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01366.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01366") -public class BenchmarkTest01366 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01366"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01367.java b/OWASP DATASET CLEANED/BenchmarkTest01367.java deleted file mode 100644 index 1aacd5c19e1acbcf589087672ef1a2526d6a1a65..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01367.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01367") -public class BenchmarkTest01367 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01367"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01368.java b/OWASP DATASET CLEANED/BenchmarkTest01368.java deleted file mode 100644 index c15df74c6b7e5b41b342da3f618471d259c2787a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01368.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01368") -public class BenchmarkTest01368 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01368"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01369.java b/OWASP DATASET CLEANED/BenchmarkTest01369.java deleted file mode 100644 index 8197eb6fbdb6bde70a743df7fd06370a137da8aa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01369.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01369") -public class BenchmarkTest01369 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01369"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a43860 = param; // assign - StringBuilder b43860 = new StringBuilder(a43860); // stick in stringbuilder - b43860.append(" SafeStuff"); // append some safe content - b43860.replace( - b43860.length() - "Chars".length(), - b43860.length(), - "Chars"); // replace some of the end content - java.util.HashMap map43860 = new java.util.HashMap(); - map43860.put("key43860", b43860.toString()); // put in a collection - String c43860 = (String) map43860.get("key43860"); // get it back out - String d43860 = c43860.substring(0, c43860.length() - 1); // extract most of it - String e43860 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d43860.getBytes()))); // B64 encode and decode it - String f43860 = e43860.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f43860); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01370.java b/OWASP DATASET CLEANED/BenchmarkTest01370.java deleted file mode 100644 index befec5742d18116e56cc835d2ca373a49e598d7e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01370.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01370") -public class BenchmarkTest01370 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01370"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01371.java b/OWASP DATASET CLEANED/BenchmarkTest01371.java deleted file mode 100644 index 38a63f2e403467e6d219a89a1130e8d90f582e17..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01371.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01371") -public class BenchmarkTest01371 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01371"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01372.java b/OWASP DATASET CLEANED/BenchmarkTest01372.java deleted file mode 100644 index 170dce3067a5b15271b5cda05a18c0ce47ecba0a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01372.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01372") -public class BenchmarkTest01372 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01372"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01373.java b/OWASP DATASET CLEANED/BenchmarkTest01373.java deleted file mode 100644 index 15dd5247d54c8df147e0d2e7ab2c1c01da9d3f68..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01373.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01373") -public class BenchmarkTest01373 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01373"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01374.java b/OWASP DATASET CLEANED/BenchmarkTest01374.java deleted file mode 100644 index 646e9fa4ebfa859bdbf6493eea0be266109ddd44..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01374.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01374") -public class BenchmarkTest01374 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01374"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01375.java b/OWASP DATASET CLEANED/BenchmarkTest01375.java deleted file mode 100644 index 5ac342464897b85c7fcdb855ffa56cb3aaa89141..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01375.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01375") -public class BenchmarkTest01375 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01375"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a33070 = param; // assign - StringBuilder b33070 = new StringBuilder(a33070); // stick in stringbuilder - b33070.append(" SafeStuff"); // append some safe content - b33070.replace( - b33070.length() - "Chars".length(), - b33070.length(), - "Chars"); // replace some of the end content - java.util.HashMap map33070 = new java.util.HashMap(); - map33070.put("key33070", b33070.toString()); // put in a collection - String c33070 = (String) map33070.get("key33070"); // get it back out - String d33070 = c33070.substring(0, c33070.length() - 1); // extract most of it - String e33070 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d33070.getBytes()))); // B64 encode and decode it - String f33070 = e33070.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f33070); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01376.java b/OWASP DATASET CLEANED/BenchmarkTest01376.java deleted file mode 100644 index 02dc7b3c9548a0688d627d8d37f5bddbdde3f049..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01376.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01376") -public class BenchmarkTest01376 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01376"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01377.java b/OWASP DATASET CLEANED/BenchmarkTest01377.java deleted file mode 100644 index 0b52e39df92ad961e281b369c919612ad6f2e7dd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01377.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01377") -public class BenchmarkTest01377 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01377"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01378.java b/OWASP DATASET CLEANED/BenchmarkTest01378.java deleted file mode 100644 index b79665d84de8a9e6b8b288c58cfe5d207c3abe71..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01378.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01378") -public class BenchmarkTest01378 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01378"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a50098 = param; // assign - StringBuilder b50098 = new StringBuilder(a50098); // stick in stringbuilder - b50098.append(" SafeStuff"); // append some safe content - b50098.replace( - b50098.length() - "Chars".length(), - b50098.length(), - "Chars"); // replace some of the end content - java.util.HashMap map50098 = new java.util.HashMap(); - map50098.put("key50098", b50098.toString()); // put in a collection - String c50098 = (String) map50098.get("key50098"); // get it back out - String d50098 = c50098.substring(0, c50098.length() - 1); // extract most of it - String e50098 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d50098.getBytes()))); // B64 encode and decode it - String f50098 = e50098.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g50098 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g50098); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01379.java b/OWASP DATASET CLEANED/BenchmarkTest01379.java deleted file mode 100644 index 9917c0bfa6ec84a988597b907ce79fa8d39377fe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01379.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01379") -public class BenchmarkTest01379 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01379"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01380.java b/OWASP DATASET CLEANED/BenchmarkTest01380.java deleted file mode 100644 index 718b461575fc42b16b97831334844a20c1235294..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01380.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01380") -public class BenchmarkTest01380 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01380"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01381.java b/OWASP DATASET CLEANED/BenchmarkTest01381.java deleted file mode 100644 index 0bc4c1c2c684ddb7facaa642d29438800e8e6f49..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01381.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01381") -public class BenchmarkTest01381 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01381"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01382.java b/OWASP DATASET CLEANED/BenchmarkTest01382.java deleted file mode 100644 index b4b3bd2f51af216c22628cd41868fb22868b801e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01382.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01382") -public class BenchmarkTest01382 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01382"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01383.java b/OWASP DATASET CLEANED/BenchmarkTest01383.java deleted file mode 100644 index 64990008b945db12577a914b4ea17faef9b739c3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01383.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01383") -public class BenchmarkTest01383 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01383"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01384.java b/OWASP DATASET CLEANED/BenchmarkTest01384.java deleted file mode 100644 index 996230e2ef61308c4b6ef5f4097484f3e1c53457..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01384.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01384") -public class BenchmarkTest01384 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01384"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new int[] {1, 2}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01385.java b/OWASP DATASET CLEANED/BenchmarkTest01385.java deleted file mode 100644 index 10abda1e7c7612f0c40cbaf25e4ae906777f41aa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01385.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01385") -public class BenchmarkTest01385 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01385"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01386.java b/OWASP DATASET CLEANED/BenchmarkTest01386.java deleted file mode 100644 index 8cb2c9e01800896e4fc14867f6ce0a27be010a84..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01386.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01386") -public class BenchmarkTest01386 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01386"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01387.java b/OWASP DATASET CLEANED/BenchmarkTest01387.java deleted file mode 100644 index 0628886c108a60f03263163b43368d6cda07b4b3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01387.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01387") -public class BenchmarkTest01387 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01387"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01388.java b/OWASP DATASET CLEANED/BenchmarkTest01388.java deleted file mode 100644 index eb5a84876a7573b737ab21801d16331a056e1a68..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01388.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01388") -public class BenchmarkTest01388 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01388"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01389.java b/OWASP DATASET CLEANED/BenchmarkTest01389.java deleted file mode 100644 index e26f60f017bac03dc69b953859740c1d203ed209..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01389.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-02/BenchmarkTest01389") -public class BenchmarkTest01389 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01389"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01390.java b/OWASP DATASET CLEANED/BenchmarkTest01390.java deleted file mode 100644 index 4779f645584044d52e0240a48f9f78a1c4b55d5d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01390.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01390") -public class BenchmarkTest01390 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01390"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01391.java b/OWASP DATASET CLEANED/BenchmarkTest01391.java deleted file mode 100644 index 27ce119633806c23130b2dc602286e8a7d9d8e4f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01391.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01391") -public class BenchmarkTest01391 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01391"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map24596 = new java.util.HashMap(); - map24596.put("keyA-24596", "a-Value"); // put some stuff in the collection - map24596.put("keyB-24596", param); // put it in a collection - map24596.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map24596.get("keyB-24596"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01392.java b/OWASP DATASET CLEANED/BenchmarkTest01392.java deleted file mode 100644 index 3e0e7bb8a130328192becd7a8a346484f053366a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01392.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01392") -public class BenchmarkTest01392 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01392"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01393.java b/OWASP DATASET CLEANED/BenchmarkTest01393.java deleted file mode 100644 index 7d5f21622afeede3a35c26da2cbcb25874756f6b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01393.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01393") -public class BenchmarkTest01393 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01393"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a57571 = param; // assign - StringBuilder b57571 = new StringBuilder(a57571); // stick in stringbuilder - b57571.append(" SafeStuff"); // append some safe content - b57571.replace( - b57571.length() - "Chars".length(), - b57571.length(), - "Chars"); // replace some of the end content - java.util.HashMap map57571 = new java.util.HashMap(); - map57571.put("key57571", b57571.toString()); // put in a collection - String c57571 = (String) map57571.get("key57571"); // get it back out - String d57571 = c57571.substring(0, c57571.length() - 1); // extract most of it - String e57571 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d57571.getBytes()))); // B64 encode and decode it - String f57571 = e57571.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g57571 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g57571); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01394.java b/OWASP DATASET CLEANED/BenchmarkTest01394.java deleted file mode 100644 index 8eccd086d361c5e973129e462b50c7b090b4ce8e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01394.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01394") -public class BenchmarkTest01394 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01394"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01395.java b/OWASP DATASET CLEANED/BenchmarkTest01395.java deleted file mode 100644 index 427dc1fe110dd09b535b49dca26a3bdc72046acb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01395.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01395") -public class BenchmarkTest01395 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01395"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01396.java b/OWASP DATASET CLEANED/BenchmarkTest01396.java deleted file mode 100644 index 3bc03b236a03b3fb036b1708cb9af925550dba41..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01396.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01396") -public class BenchmarkTest01396 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01396"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01397.java b/OWASP DATASET CLEANED/BenchmarkTest01397.java deleted file mode 100644 index be0c704e2ad4909c10223ae1313e8b2f4b3091a3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01397.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01397") -public class BenchmarkTest01397 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest01397"); - if (values != null) param = values[0]; - } - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01398.java b/OWASP DATASET CLEANED/BenchmarkTest01398.java deleted file mode 100644 index f79a7a6be21dd9cdec2cacc277c0a9cac910b80d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01398.java +++ /dev/null @@ -1,198 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01398") -public class BenchmarkTest01398 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01398")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a37227 = param; // assign - StringBuilder b37227 = new StringBuilder(a37227); // stick in stringbuilder - b37227.append(" SafeStuff"); // append some safe content - b37227.replace( - b37227.length() - "Chars".length(), - b37227.length(), - "Chars"); // replace some of the end content - java.util.HashMap map37227 = new java.util.HashMap(); - map37227.put("key37227", b37227.toString()); // put in a collection - String c37227 = (String) map37227.get("key37227"); // get it back out - String d37227 = c37227.substring(0, c37227.length() - 1); // extract most of it - String e37227 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d37227.getBytes()))); // B64 encode and decode it - String f37227 = e37227.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g37227 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g37227); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01399.java b/OWASP DATASET CLEANED/BenchmarkTest01399.java deleted file mode 100644 index 4a31a78610270538754eb3f92a6c65c5cb0db2ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01399.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01399") -public class BenchmarkTest01399 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01399")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01400.java b/OWASP DATASET CLEANED/BenchmarkTest01400.java deleted file mode 100644 index 497898c8ef8cd6b6a0d75411008db7ef4c18377b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01400.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01400") -public class BenchmarkTest01400 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01400")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01401.java b/OWASP DATASET CLEANED/BenchmarkTest01401.java deleted file mode 100644 index be900cb26743834b1759394b4a15f43525ee8973..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01401.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01401") -public class BenchmarkTest01401 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01401")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01402.java b/OWASP DATASET CLEANED/BenchmarkTest01402.java deleted file mode 100644 index df7a933270a9c5e1313db251caf3c521e9eb6ec8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01402.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01402") -public class BenchmarkTest01402 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01402")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01403.java b/OWASP DATASET CLEANED/BenchmarkTest01403.java deleted file mode 100644 index bf7a95c6ae07d70acacd22590966301643714e9a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01403.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01403") -public class BenchmarkTest01403 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01403")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01404.java b/OWASP DATASET CLEANED/BenchmarkTest01404.java deleted file mode 100644 index 6621640d494821109ecb188c2d73090bd88068ba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01404.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01404") -public class BenchmarkTest01404 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01404")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a75056 = param; // assign - StringBuilder b75056 = new StringBuilder(a75056); // stick in stringbuilder - b75056.append(" SafeStuff"); // append some safe content - b75056.replace( - b75056.length() - "Chars".length(), - b75056.length(), - "Chars"); // replace some of the end content - java.util.HashMap map75056 = new java.util.HashMap(); - map75056.put("key75056", b75056.toString()); // put in a collection - String c75056 = (String) map75056.get("key75056"); // get it back out - String d75056 = c75056.substring(0, c75056.length() - 1); // extract most of it - String e75056 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d75056.getBytes()))); // B64 encode and decode it - String f75056 = e75056.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g75056 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g75056); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01405.java b/OWASP DATASET CLEANED/BenchmarkTest01405.java deleted file mode 100644 index 4463a1497c24f9f3c1a90b3624edf863e3aaed78..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01405.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01405") -public class BenchmarkTest01405 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01405")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01406.java b/OWASP DATASET CLEANED/BenchmarkTest01406.java deleted file mode 100644 index a0def93987895fcd72e9c761b024f5ec7206e20e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01406.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01406") -public class BenchmarkTest01406 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01406")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01407.java b/OWASP DATASET CLEANED/BenchmarkTest01407.java deleted file mode 100644 index ac8be5ab91ce4e5c411c090d9ec0f0a8715ca3be..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01407.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01407") -public class BenchmarkTest01407 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01407")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01408.java b/OWASP DATASET CLEANED/BenchmarkTest01408.java deleted file mode 100644 index 14aa7e6737171d8ded2d84894fca3bb109981efa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01408.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01408") -public class BenchmarkTest01408 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01408")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01409.java b/OWASP DATASET CLEANED/BenchmarkTest01409.java deleted file mode 100644 index 91c608c11cdc0ba4aade2f74a0fa74ead9a8c4d1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01409.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01409") -public class BenchmarkTest01409 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01409")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map58007 = new java.util.HashMap(); - map58007.put("keyA-58007", "a_Value"); // put some stuff in the collection - map58007.put("keyB-58007", param); // put it in a collection - map58007.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map58007.get("keyB-58007"); // get it back out - bar = (String) map58007.get("keyA-58007"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01410.java b/OWASP DATASET CLEANED/BenchmarkTest01410.java deleted file mode 100644 index dc2f92b355ce052db023a8436d2969e3c7df8057..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01410.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01410") -public class BenchmarkTest01410 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01410")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01411.java b/OWASP DATASET CLEANED/BenchmarkTest01411.java deleted file mode 100644 index 194a0666f672165805f0e12c72c6dfc1efe812f5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01411.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01411") -public class BenchmarkTest01411 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01411")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01412.java b/OWASP DATASET CLEANED/BenchmarkTest01412.java deleted file mode 100644 index bbe2f235779905bea1a0448aae95968efa44018f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01412.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01412") -public class BenchmarkTest01412 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01412")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01413.java b/OWASP DATASET CLEANED/BenchmarkTest01413.java deleted file mode 100644 index 46cc73c4226b85348681db571adeff1b279d310a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01413.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01413") -public class BenchmarkTest01413 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01413")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01414.java b/OWASP DATASET CLEANED/BenchmarkTest01414.java deleted file mode 100644 index c89ad3d560344210148fc99e5a82a700cb54a5c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01414.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01414") -public class BenchmarkTest01414 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01414")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01415.java b/OWASP DATASET CLEANED/BenchmarkTest01415.java deleted file mode 100644 index b5646c8ff5b25ddf551743264a6f30ea1ef1714e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01415.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01415") -public class BenchmarkTest01415 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01415")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01416.java b/OWASP DATASET CLEANED/BenchmarkTest01416.java deleted file mode 100644 index 927487a0c85d67ab5e9caef75a36e0068518bd27..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01416.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01416") -public class BenchmarkTest01416 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01416")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01417.java b/OWASP DATASET CLEANED/BenchmarkTest01417.java deleted file mode 100644 index 3ab1f0fe47027231536e856796cf22db80a98052..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01417.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01417") -public class BenchmarkTest01417 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01417")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01418.java b/OWASP DATASET CLEANED/BenchmarkTest01418.java deleted file mode 100644 index 67f7b285390854df1826c429c1f87ea25321d5ca..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01418.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01418") -public class BenchmarkTest01418 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01418")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01419.java b/OWASP DATASET CLEANED/BenchmarkTest01419.java deleted file mode 100644 index a1b9f23a548e9d2556e3c8b36e58c2f21801ca55..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01419.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01419") -public class BenchmarkTest01419 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01419")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01420.java b/OWASP DATASET CLEANED/BenchmarkTest01420.java deleted file mode 100644 index 818cff8a7bb28cc65d027762b3e903c26b4356b1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01420.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01420") -public class BenchmarkTest01420 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01420")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01421.java b/OWASP DATASET CLEANED/BenchmarkTest01421.java deleted file mode 100644 index 735fba6ddfc3c7370ce3aaf543da41e693ef4fd1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01421.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01421") -public class BenchmarkTest01421 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01421")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01422.java b/OWASP DATASET CLEANED/BenchmarkTest01422.java deleted file mode 100644 index 3f6d3ace21fc58d99df5a66713e1e3348978d3ea..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01422.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01422") -public class BenchmarkTest01422 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01422")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map80775 = new java.util.HashMap(); - map80775.put("keyA-80775", "a_Value"); // put some stuff in the collection - map80775.put("keyB-80775", param); // put it in a collection - map80775.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map80775.get("keyB-80775"); // get it back out - bar = (String) map80775.get("keyA-80775"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01423.java b/OWASP DATASET CLEANED/BenchmarkTest01423.java deleted file mode 100644 index fa7aac4af6cb55dd392d1f04799ec3bea563c2ae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01423.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01423") -public class BenchmarkTest01423 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01423")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01424.java b/OWASP DATASET CLEANED/BenchmarkTest01424.java deleted file mode 100644 index 75197a2c32caeb1eade1e279a56a7bb0b3df8c34..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01424.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01424") -public class BenchmarkTest01424 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01424")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz93549 = new StringBuilder(param); - String bar = sbxyz93549.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01425.java b/OWASP DATASET CLEANED/BenchmarkTest01425.java deleted file mode 100644 index 36a9b27bf289509bd381a49f26b14b1407851aaa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01425.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01425") -public class BenchmarkTest01425 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01425")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01426.java b/OWASP DATASET CLEANED/BenchmarkTest01426.java deleted file mode 100644 index 943e2d7aa949ea0fb8423a2e45b6566e5518825b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01426.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01426") -public class BenchmarkTest01426 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01426")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01427.java b/OWASP DATASET CLEANED/BenchmarkTest01427.java deleted file mode 100644 index 4b2a062510ec9a04816cfc9832c5f0a7d5678534..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01427.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01427") -public class BenchmarkTest01427 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01427")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01428.java b/OWASP DATASET CLEANED/BenchmarkTest01428.java deleted file mode 100644 index 3e13746ddbde2003a3f01bfd5506ea045ff4da03..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01428.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01428") -public class BenchmarkTest01428 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01428")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01429.java b/OWASP DATASET CLEANED/BenchmarkTest01429.java deleted file mode 100644 index 2aabf4ddf8ff1c543cdc001724cef02c38616228..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01429.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01429") -public class BenchmarkTest01429 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01429")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01430.java b/OWASP DATASET CLEANED/BenchmarkTest01430.java deleted file mode 100644 index 3785a75bad7c5f19863280bd54b1b66bdb76a351..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01430.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01430") -public class BenchmarkTest01430 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01430")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01431.java b/OWASP DATASET CLEANED/BenchmarkTest01431.java deleted file mode 100644 index ca2adc2cdbf61b9f3acf4bf7681d3d52c4888950..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01431.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01431") -public class BenchmarkTest01431 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01431")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01432.java b/OWASP DATASET CLEANED/BenchmarkTest01432.java deleted file mode 100644 index 5a649ef1e9389e5ee1564ca3ae1ceb9d27056fd6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01432.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01432") -public class BenchmarkTest01432 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01432")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz18866 = new StringBuilder(param); - bar = - sbxyz18866 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01433.java b/OWASP DATASET CLEANED/BenchmarkTest01433.java deleted file mode 100644 index a2bb5ddc3307ad75e77a0fc30eb53d7ec8d5007a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01433.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01433") -public class BenchmarkTest01433 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01433")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01434.java b/OWASP DATASET CLEANED/BenchmarkTest01434.java deleted file mode 100644 index 59e5e98f59c3bacb3566b126f35daa1474b3ce44..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01434.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01434") -public class BenchmarkTest01434 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01434")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01435.java b/OWASP DATASET CLEANED/BenchmarkTest01435.java deleted file mode 100644 index 270baddbacfcb56c49394f8a5767439845c6b006..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01435.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01435") -public class BenchmarkTest01435 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01435")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01436.java b/OWASP DATASET CLEANED/BenchmarkTest01436.java deleted file mode 100644 index cf1c32f422fc9cdb01afad17e96a5b8abd23ceed..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01436.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01436") -public class BenchmarkTest01436 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01436")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01437.java b/OWASP DATASET CLEANED/BenchmarkTest01437.java deleted file mode 100644 index b65ac071f5fc3b1dbfd9b102d0bf4076efe871a5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01437.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01437") -public class BenchmarkTest01437 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01437")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01438.java b/OWASP DATASET CLEANED/BenchmarkTest01438.java deleted file mode 100644 index 7e8d9a22b4728b45907aae7280833d6f52b2f40e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01438.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01438") -public class BenchmarkTest01438 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01438")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a32762 = param; // assign - StringBuilder b32762 = new StringBuilder(a32762); // stick in stringbuilder - b32762.append(" SafeStuff"); // append some safe content - b32762.replace( - b32762.length() - "Chars".length(), - b32762.length(), - "Chars"); // replace some of the end content - java.util.HashMap map32762 = new java.util.HashMap(); - map32762.put("key32762", b32762.toString()); // put in a collection - String c32762 = (String) map32762.get("key32762"); // get it back out - String d32762 = c32762.substring(0, c32762.length() - 1); // extract most of it - String e32762 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d32762.getBytes()))); // B64 encode and decode it - String f32762 = e32762.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f32762); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01439.java b/OWASP DATASET CLEANED/BenchmarkTest01439.java deleted file mode 100644 index 27d0c755952407c3d06000317d3d4d426064a47b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01439.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01439") -public class BenchmarkTest01439 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01439")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map95590 = new java.util.HashMap(); - map95590.put("keyA-95590", "a_Value"); // put some stuff in the collection - map95590.put("keyB-95590", param); // put it in a collection - map95590.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map95590.get("keyB-95590"); // get it back out - bar = (String) map95590.get("keyA-95590"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01440.java b/OWASP DATASET CLEANED/BenchmarkTest01440.java deleted file mode 100644 index 46d93a6124459cdf929cf676bbac3fa5732f2700..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01440.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01440") -public class BenchmarkTest01440 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01440")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01441.java b/OWASP DATASET CLEANED/BenchmarkTest01441.java deleted file mode 100644 index d0170018ff952754817eaf1c42b13bb2ba23bda0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01441.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01441") -public class BenchmarkTest01441 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01441")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01442.java b/OWASP DATASET CLEANED/BenchmarkTest01442.java deleted file mode 100644 index b5511659b5710ca75265da3523ac81fe6a621a5b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01442.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01442") -public class BenchmarkTest01442 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01442")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01443.java b/OWASP DATASET CLEANED/BenchmarkTest01443.java deleted file mode 100644 index b2744d912da6482eee562346567b8f85833e2c74..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01443.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01443") -public class BenchmarkTest01443 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01443")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01444.java b/OWASP DATASET CLEANED/BenchmarkTest01444.java deleted file mode 100644 index b286485e19142eeec230dc0cdc13bbd134980fdc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01444.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01444") -public class BenchmarkTest01444 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01444")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01445.java b/OWASP DATASET CLEANED/BenchmarkTest01445.java deleted file mode 100644 index bdae8cb9e947bbd6114601c41bfee804e34bec3c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01445.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01445") -public class BenchmarkTest01445 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01445")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map3083 = new java.util.HashMap(); - map3083.put("keyA-3083", "a_Value"); // put some stuff in the collection - map3083.put("keyB-3083", param); // put it in a collection - map3083.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map3083.get("keyB-3083"); // get it back out - bar = (String) map3083.get("keyA-3083"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01446.java b/OWASP DATASET CLEANED/BenchmarkTest01446.java deleted file mode 100644 index 32fc204597e48c2e73749f41ccd5288f05249c14..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01446.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01446") -public class BenchmarkTest01446 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01446")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01447.java b/OWASP DATASET CLEANED/BenchmarkTest01447.java deleted file mode 100644 index 5e4c1b4ea562ac44e2315446e0ec5d60078e529b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01447.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01447") -public class BenchmarkTest01447 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01447")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01448.java b/OWASP DATASET CLEANED/BenchmarkTest01448.java deleted file mode 100644 index f4647845d7fab2e0c22bbb3aa2391b6c2310c42c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01448.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01448") -public class BenchmarkTest01448 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01448")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01449.java b/OWASP DATASET CLEANED/BenchmarkTest01449.java deleted file mode 100644 index 9eca5369853a289838ceb465047383ef94407f70..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01449.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01449") -public class BenchmarkTest01449 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01449")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01450.java b/OWASP DATASET CLEANED/BenchmarkTest01450.java deleted file mode 100644 index 4f3ed3d9add79dd7acaa52e479d9b257692cbb92..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01450.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01450") -public class BenchmarkTest01450 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01450")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map75877 = new java.util.HashMap(); - map75877.put("keyA-75877", "a_Value"); // put some stuff in the collection - map75877.put("keyB-75877", param); // put it in a collection - map75877.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map75877.get("keyB-75877"); // get it back out - bar = (String) map75877.get("keyA-75877"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01451.java b/OWASP DATASET CLEANED/BenchmarkTest01451.java deleted file mode 100644 index cc1378dddfe252158fae943c21d4bfe4c7028f51..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01451.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01451") -public class BenchmarkTest01451 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01451")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01452.java b/OWASP DATASET CLEANED/BenchmarkTest01452.java deleted file mode 100644 index e425f02f23f8900cbbd591ff047849e4a8c9e975..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01452.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01452") -public class BenchmarkTest01452 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01452")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01453.java b/OWASP DATASET CLEANED/BenchmarkTest01453.java deleted file mode 100644 index 65a130c20c4523a5dd0f784fdf41fc380e55ccf0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01453.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01453") -public class BenchmarkTest01453 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01453")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01454.java b/OWASP DATASET CLEANED/BenchmarkTest01454.java deleted file mode 100644 index 1753dcbe8bfb1fd3cebfc4cf0b9bdc26483be81b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01454.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01454") -public class BenchmarkTest01454 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01454")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01455.java b/OWASP DATASET CLEANED/BenchmarkTest01455.java deleted file mode 100644 index 96dcc9be934411e08310f33a482923808c3cfd58..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01455.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01455") -public class BenchmarkTest01455 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01455")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01456.java b/OWASP DATASET CLEANED/BenchmarkTest01456.java deleted file mode 100644 index a3ad1fbe2b301e234798d655c4b66662ae33ed42..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01456.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01456") -public class BenchmarkTest01456 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01456")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01457.java b/OWASP DATASET CLEANED/BenchmarkTest01457.java deleted file mode 100644 index c7c1fd81df0b6799151259232948d8be866f3c99..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01457.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01457") -public class BenchmarkTest01457 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01457")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01458.java b/OWASP DATASET CLEANED/BenchmarkTest01458.java deleted file mode 100644 index b6cced11253e1d3bdc675e4e201bbbf75844bab4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01458.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01458") -public class BenchmarkTest01458 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01458")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a34936 = param; // assign - StringBuilder b34936 = new StringBuilder(a34936); // stick in stringbuilder - b34936.append(" SafeStuff"); // append some safe content - b34936.replace( - b34936.length() - "Chars".length(), - b34936.length(), - "Chars"); // replace some of the end content - java.util.HashMap map34936 = new java.util.HashMap(); - map34936.put("key34936", b34936.toString()); // put in a collection - String c34936 = (String) map34936.get("key34936"); // get it back out - String d34936 = c34936.substring(0, c34936.length() - 1); // extract most of it - String e34936 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d34936.getBytes()))); // B64 encode and decode it - String f34936 = e34936.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f34936); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01459.java b/OWASP DATASET CLEANED/BenchmarkTest01459.java deleted file mode 100644 index c18df748546d7ce3e4348361556f20556ca0ae51..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01459.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01459") -public class BenchmarkTest01459 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01459")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01460.java b/OWASP DATASET CLEANED/BenchmarkTest01460.java deleted file mode 100644 index 9bff7da7620ba3525be6211a66feebd3863d6f04..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01460.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01460") -public class BenchmarkTest01460 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01460")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map72098 = new java.util.HashMap(); - map72098.put("keyA-72098", "a-Value"); // put some stuff in the collection - map72098.put("keyB-72098", param); // put it in a collection - map72098.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map72098.get("keyB-72098"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01461.java b/OWASP DATASET CLEANED/BenchmarkTest01461.java deleted file mode 100644 index 98472724a141c46554b99db8e13b78966476def7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01461.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01461") -public class BenchmarkTest01461 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01461")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map96401 = new java.util.HashMap(); - map96401.put("keyA-96401", "a_Value"); // put some stuff in the collection - map96401.put("keyB-96401", param); // put it in a collection - map96401.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map96401.get("keyB-96401"); // get it back out - bar = (String) map96401.get("keyA-96401"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01462.java b/OWASP DATASET CLEANED/BenchmarkTest01462.java deleted file mode 100644 index ba8981e8176fb33a9351bef2ee873698556a17d6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01462.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01462") -public class BenchmarkTest01462 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01462")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01463.java b/OWASP DATASET CLEANED/BenchmarkTest01463.java deleted file mode 100644 index 43c8d6aafacaca25207dfb6dab2145bd472c01b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01463.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01463") -public class BenchmarkTest01463 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01463")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01464.java b/OWASP DATASET CLEANED/BenchmarkTest01464.java deleted file mode 100644 index 44db231f40588a100e311a17d4eac8bfc2827490..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01464.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01464") -public class BenchmarkTest01464 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01464")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01465.java b/OWASP DATASET CLEANED/BenchmarkTest01465.java deleted file mode 100644 index ed146cd715d7e62f3f5c7518932bfac282b1f97c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01465.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01465") -public class BenchmarkTest01465 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01465")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01466.java b/OWASP DATASET CLEANED/BenchmarkTest01466.java deleted file mode 100644 index 624db13c539bcd5a076d1e404e9c4a4f116cd259..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01466.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01466") -public class BenchmarkTest01466 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01466")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01467.java b/OWASP DATASET CLEANED/BenchmarkTest01467.java deleted file mode 100644 index d1c7dfa97b8a21ded2c0219424cfd6d0dfa71e52..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01467.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01467") -public class BenchmarkTest01467 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01467")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map34856 = new java.util.HashMap(); - map34856.put("keyA-34856", "a_Value"); // put some stuff in the collection - map34856.put("keyB-34856", param); // put it in a collection - map34856.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map34856.get("keyB-34856"); // get it back out - bar = (String) map34856.get("keyA-34856"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01468.java b/OWASP DATASET CLEANED/BenchmarkTest01468.java deleted file mode 100644 index 6dbb3e4359d5f8b202431d974ea95a90332b6627..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01468.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01468") -public class BenchmarkTest01468 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01468")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01469.java b/OWASP DATASET CLEANED/BenchmarkTest01469.java deleted file mode 100644 index d81ecd17073db63ec875dee133ec0b90a9100b8c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01469.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01469") -public class BenchmarkTest01469 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01469")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a83916 = param; // assign - StringBuilder b83916 = new StringBuilder(a83916); // stick in stringbuilder - b83916.append(" SafeStuff"); // append some safe content - b83916.replace( - b83916.length() - "Chars".length(), - b83916.length(), - "Chars"); // replace some of the end content - java.util.HashMap map83916 = new java.util.HashMap(); - map83916.put("key83916", b83916.toString()); // put in a collection - String c83916 = (String) map83916.get("key83916"); // get it back out - String d83916 = c83916.substring(0, c83916.length() - 1); // extract most of it - String e83916 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d83916.getBytes()))); // B64 encode and decode it - String f83916 = e83916.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g83916 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g83916); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01470.java b/OWASP DATASET CLEANED/BenchmarkTest01470.java deleted file mode 100644 index cbd399a96432309f19f861ea3ff793b5dcf7adb5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01470.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01470") -public class BenchmarkTest01470 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01470")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01471.java b/OWASP DATASET CLEANED/BenchmarkTest01471.java deleted file mode 100644 index 92ff4a94552d88a63f9b1227256ab8702cbefba9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01471.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01471") -public class BenchmarkTest01471 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01471")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01472.java b/OWASP DATASET CLEANED/BenchmarkTest01472.java deleted file mode 100644 index b5c87b7b3d9046b2b7789bf53ef94d93e59c10a2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01472.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01472") -public class BenchmarkTest01472 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01472")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a60049 = param; // assign - StringBuilder b60049 = new StringBuilder(a60049); // stick in stringbuilder - b60049.append(" SafeStuff"); // append some safe content - b60049.replace( - b60049.length() - "Chars".length(), - b60049.length(), - "Chars"); // replace some of the end content - java.util.HashMap map60049 = new java.util.HashMap(); - map60049.put("key60049", b60049.toString()); // put in a collection - String c60049 = (String) map60049.get("key60049"); // get it back out - String d60049 = c60049.substring(0, c60049.length() - 1); // extract most of it - String e60049 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d60049.getBytes()))); // B64 encode and decode it - String f60049 = e60049.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g60049 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g60049); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01473.java b/OWASP DATASET CLEANED/BenchmarkTest01473.java deleted file mode 100644 index c7807549085c33e7dea53a1a4980927a2b548dac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01473.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01473") -public class BenchmarkTest01473 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01473")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01474.java b/OWASP DATASET CLEANED/BenchmarkTest01474.java deleted file mode 100644 index 6a991c82bd2c17b234cc887936e438e49702d4a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01474.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01474") -public class BenchmarkTest01474 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01474")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01475.java b/OWASP DATASET CLEANED/BenchmarkTest01475.java deleted file mode 100644 index a6544d1b0d0bb2f697a46508b904d4bd6d939051..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01475.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01475") -public class BenchmarkTest01475 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01475")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01476.java b/OWASP DATASET CLEANED/BenchmarkTest01476.java deleted file mode 100644 index 6bb213696e203e321f392a38947ef6f11c4ce53f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01476.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01476") -public class BenchmarkTest01476 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01476")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01477.java b/OWASP DATASET CLEANED/BenchmarkTest01477.java deleted file mode 100644 index cde5f9c9df53cf94475410506edf11ae39adb1ba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01477.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01477") -public class BenchmarkTest01477 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01477")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01478.java b/OWASP DATASET CLEANED/BenchmarkTest01478.java deleted file mode 100644 index 954fc12b3dd1076c4b0ac0181cf34d082158aa39..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01478.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01478") -public class BenchmarkTest01478 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01478")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01479.java b/OWASP DATASET CLEANED/BenchmarkTest01479.java deleted file mode 100644 index 5be03289440d1ac859791c439009c01ca8355557..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01479.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01479") -public class BenchmarkTest01479 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest01479")) { - param = name; - flag = false; - } - } - } - } - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01480.java b/OWASP DATASET CLEANED/BenchmarkTest01480.java deleted file mode 100644 index 0e8b4f57b8039beee4500557034151bc6774ead3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01480.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01480") -public class BenchmarkTest01480 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01480"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a55670 = param; // assign - StringBuilder b55670 = new StringBuilder(a55670); // stick in stringbuilder - b55670.append(" SafeStuff"); // append some safe content - b55670.replace( - b55670.length() - "Chars".length(), - b55670.length(), - "Chars"); // replace some of the end content - java.util.HashMap map55670 = new java.util.HashMap(); - map55670.put("key55670", b55670.toString()); // put in a collection - String c55670 = (String) map55670.get("key55670"); // get it back out - String d55670 = c55670.substring(0, c55670.length() - 1); // extract most of it - String e55670 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d55670.getBytes()))); // B64 encode and decode it - String f55670 = e55670.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f55670); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01481.java b/OWASP DATASET CLEANED/BenchmarkTest01481.java deleted file mode 100644 index 012174b2d6f6c778f58ee4dfb84d506fcf49afbe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01481.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01481") -public class BenchmarkTest01481 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01481"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map69587 = new java.util.HashMap(); - map69587.put("keyA-69587", "a_Value"); // put some stuff in the collection - map69587.put("keyB-69587", param); // put it in a collection - map69587.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map69587.get("keyB-69587"); // get it back out - bar = (String) map69587.get("keyA-69587"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01482.java b/OWASP DATASET CLEANED/BenchmarkTest01482.java deleted file mode 100644 index ee85786cc03fdb351fe0ecf8ea45f7aed1865b84..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01482.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01482") -public class BenchmarkTest01482 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01482"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01483.java b/OWASP DATASET CLEANED/BenchmarkTest01483.java deleted file mode 100644 index a9dd9f76949e9dcb02dc3e3808eec9df6425d46a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01483.java +++ /dev/null @@ -1,175 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01483") -public class BenchmarkTest01483 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01483"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01484.java b/OWASP DATASET CLEANED/BenchmarkTest01484.java deleted file mode 100644 index 723f77504887c2a180adba043c82b9e0889632c1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01484.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01484") -public class BenchmarkTest01484 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01484"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01485.java b/OWASP DATASET CLEANED/BenchmarkTest01485.java deleted file mode 100644 index 6b6731e9f238491f0fbdc0ef08e23df572516156..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01485.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01485") -public class BenchmarkTest01485 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01485"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01486.java b/OWASP DATASET CLEANED/BenchmarkTest01486.java deleted file mode 100644 index 4156ef3dc5f000a2aa1443f1f7df0a152e1f1be3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01486.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01486") -public class BenchmarkTest01486 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01486"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01487.java b/OWASP DATASET CLEANED/BenchmarkTest01487.java deleted file mode 100644 index 08ae77f7ebfae343017be035c23c111c483b4501..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01487.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01487") -public class BenchmarkTest01487 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01487"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map78614 = new java.util.HashMap(); - map78614.put("keyA-78614", "a_Value"); // put some stuff in the collection - map78614.put("keyB-78614", param); // put it in a collection - map78614.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map78614.get("keyB-78614"); // get it back out - bar = (String) map78614.get("keyA-78614"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01488.java b/OWASP DATASET CLEANED/BenchmarkTest01488.java deleted file mode 100644 index 6c9f01de93fe6fea1f1805a4c649dce7997bf37f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01488.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01488") -public class BenchmarkTest01488 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01488"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01489.java b/OWASP DATASET CLEANED/BenchmarkTest01489.java deleted file mode 100644 index 7354c5c7d9140ea5de63ba3ff29d7dc3cced2fc2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01489.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01489") -public class BenchmarkTest01489 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01489"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01490.java b/OWASP DATASET CLEANED/BenchmarkTest01490.java deleted file mode 100644 index c29131fe730eb7a911a39fcd2d21bc7788d0197b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01490.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01490") -public class BenchmarkTest01490 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01490"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map58491 = new java.util.HashMap(); - map58491.put("keyA-58491", "a-Value"); // put some stuff in the collection - map58491.put("keyB-58491", param); // put it in a collection - map58491.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map58491.get("keyB-58491"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01491.java b/OWASP DATASET CLEANED/BenchmarkTest01491.java deleted file mode 100644 index e1ec9a6a3371f57163cd42c903cf02fdb1e68e57..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01491.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01491") -public class BenchmarkTest01491 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01491"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a55812 = param; // assign - StringBuilder b55812 = new StringBuilder(a55812); // stick in stringbuilder - b55812.append(" SafeStuff"); // append some safe content - b55812.replace( - b55812.length() - "Chars".length(), - b55812.length(), - "Chars"); // replace some of the end content - java.util.HashMap map55812 = new java.util.HashMap(); - map55812.put("key55812", b55812.toString()); // put in a collection - String c55812 = (String) map55812.get("key55812"); // get it back out - String d55812 = c55812.substring(0, c55812.length() - 1); // extract most of it - String e55812 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d55812.getBytes()))); // B64 encode and decode it - String f55812 = e55812.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g55812 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g55812); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01492.java b/OWASP DATASET CLEANED/BenchmarkTest01492.java deleted file mode 100644 index 1b92dadc985704c72b5cec86ebc228e307a007a6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01492.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01492") -public class BenchmarkTest01492 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01492"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01493.java b/OWASP DATASET CLEANED/BenchmarkTest01493.java deleted file mode 100644 index 3949a4431b45c5cc1b2790d3c68ab7234803a15a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01493.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01493") -public class BenchmarkTest01493 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01493"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map71009 = new java.util.HashMap(); - map71009.put("keyA-71009", "a_Value"); // put some stuff in the collection - map71009.put("keyB-71009", param); // put it in a collection - map71009.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map71009.get("keyB-71009"); // get it back out - bar = (String) map71009.get("keyA-71009"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01494.java b/OWASP DATASET CLEANED/BenchmarkTest01494.java deleted file mode 100644 index f0f522a23d889939ba4fb5efc203250717b38bff..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01494.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01494") -public class BenchmarkTest01494 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01494"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01495.java b/OWASP DATASET CLEANED/BenchmarkTest01495.java deleted file mode 100644 index 5e12b7cac5ae7091fa14fade410246472106de7c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01495.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01495") -public class BenchmarkTest01495 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01495"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01496.java b/OWASP DATASET CLEANED/BenchmarkTest01496.java deleted file mode 100644 index 6875fba2fe2716215297d3820a4af2207b39d03b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01496.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01496") -public class BenchmarkTest01496 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01496"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01497.java b/OWASP DATASET CLEANED/BenchmarkTest01497.java deleted file mode 100644 index ba147afec98e9fd8a1e9859040189064f546b4a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01497.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01497") -public class BenchmarkTest01497 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01497"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01498.java b/OWASP DATASET CLEANED/BenchmarkTest01498.java deleted file mode 100644 index 931d166cc8dd4bfd77b39268529ebb3d0f3a64bf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01498.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01498") -public class BenchmarkTest01498 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01498"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01499.java b/OWASP DATASET CLEANED/BenchmarkTest01499.java deleted file mode 100644 index 98625b644fe38426e613b300c79d60dd117642db..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01499.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01499") -public class BenchmarkTest01499 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01499"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01500.java b/OWASP DATASET CLEANED/BenchmarkTest01500.java deleted file mode 100644 index c437f430682e5d0080a7125375e8578f13342c7f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01500.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01500") -public class BenchmarkTest01500 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01500"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map3545 = new java.util.HashMap(); - map3545.put("keyA-3545", "a-Value"); // put some stuff in the collection - map3545.put("keyB-3545", param); // put it in a collection - map3545.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map3545.get("keyB-3545"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01501.java b/OWASP DATASET CLEANED/BenchmarkTest01501.java deleted file mode 100644 index 9a894e761bfa7d2738cace47c7e6c9d9a9f1de49..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01501.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01501") -public class BenchmarkTest01501 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01501"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01502.java b/OWASP DATASET CLEANED/BenchmarkTest01502.java deleted file mode 100644 index 26ebc0345e29027909917d7807c8c8dbd7c68712..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01502.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01502") -public class BenchmarkTest01502 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01502"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a43640 = param; // assign - StringBuilder b43640 = new StringBuilder(a43640); // stick in stringbuilder - b43640.append(" SafeStuff"); // append some safe content - b43640.replace( - b43640.length() - "Chars".length(), - b43640.length(), - "Chars"); // replace some of the end content - java.util.HashMap map43640 = new java.util.HashMap(); - map43640.put("key43640", b43640.toString()); // put in a collection - String c43640 = (String) map43640.get("key43640"); // get it back out - String d43640 = c43640.substring(0, c43640.length() - 1); // extract most of it - String e43640 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d43640.getBytes()))); // B64 encode and decode it - String f43640 = e43640.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g43640 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g43640); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01503.java b/OWASP DATASET CLEANED/BenchmarkTest01503.java deleted file mode 100644 index cda7551f6fe835bf8fbd6f79a84f566c67d53c4a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01503.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01503") -public class BenchmarkTest01503 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01503"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01504.java b/OWASP DATASET CLEANED/BenchmarkTest01504.java deleted file mode 100644 index 009b5642097e153fb430e3cab278d492f5d3c753..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01504.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01504") -public class BenchmarkTest01504 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01504"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01505.java b/OWASP DATASET CLEANED/BenchmarkTest01505.java deleted file mode 100644 index 88ede36e03d3214e16f76169421d57767459535d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01505.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01505") -public class BenchmarkTest01505 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01505"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01506.java b/OWASP DATASET CLEANED/BenchmarkTest01506.java deleted file mode 100644 index c90a1944fbc9758dcc92ad988e0f89a64e66e7c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01506.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01506") -public class BenchmarkTest01506 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01506"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01507.java b/OWASP DATASET CLEANED/BenchmarkTest01507.java deleted file mode 100644 index bd699c3f392b17e9153debbfed9a01070cb2227a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01507.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01507") -public class BenchmarkTest01507 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01507"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01508.java b/OWASP DATASET CLEANED/BenchmarkTest01508.java deleted file mode 100644 index 04c21ddee3e6ffe676b371106ea1344abfe52653..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01508.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-02/BenchmarkTest01508") -public class BenchmarkTest01508 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01508"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01509.java b/OWASP DATASET CLEANED/BenchmarkTest01509.java deleted file mode 100644 index f0810134d405be8cf7345cb6ea848481946c2ac3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01509.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01509") -public class BenchmarkTest01509 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01509"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01510.java b/OWASP DATASET CLEANED/BenchmarkTest01510.java deleted file mode 100644 index 8f942efe7d0087e08fd3158d349703a59f43be39..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01510.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01510") -public class BenchmarkTest01510 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01510"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01511.java b/OWASP DATASET CLEANED/BenchmarkTest01511.java deleted file mode 100644 index 40c7c434b1547b228c0116b8ddb8c199e413855d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01511.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01511") -public class BenchmarkTest01511 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01511"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01512.java b/OWASP DATASET CLEANED/BenchmarkTest01512.java deleted file mode 100644 index 34cde777ca890ab6d0b800ecc08a6dd730470579..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01512.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01512") -public class BenchmarkTest01512 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01512"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz76583 = new StringBuilder(param); - bar = - sbxyz76583 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01513.java b/OWASP DATASET CLEANED/BenchmarkTest01513.java deleted file mode 100644 index 445e1d813e47052e751326b2cec09c829fecf681..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01513.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01513") -public class BenchmarkTest01513 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01513"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01514.java b/OWASP DATASET CLEANED/BenchmarkTest01514.java deleted file mode 100644 index 88df38e6f4134361e496d45ee2275e5f97b3182e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01514.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01514") -public class BenchmarkTest01514 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01514"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map56316 = new java.util.HashMap(); - map56316.put("keyA-56316", "a_Value"); // put some stuff in the collection - map56316.put("keyB-56316", param); // put it in a collection - map56316.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map56316.get("keyB-56316"); // get it back out - bar = (String) map56316.get("keyA-56316"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01515.java b/OWASP DATASET CLEANED/BenchmarkTest01515.java deleted file mode 100644 index 52f436f20b504923e5346fb8fb0a1779acdef5d2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01515.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01515") -public class BenchmarkTest01515 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01515"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a84124 = param; // assign - StringBuilder b84124 = new StringBuilder(a84124); // stick in stringbuilder - b84124.append(" SafeStuff"); // append some safe content - b84124.replace( - b84124.length() - "Chars".length(), - b84124.length(), - "Chars"); // replace some of the end content - java.util.HashMap map84124 = new java.util.HashMap(); - map84124.put("key84124", b84124.toString()); // put in a collection - String c84124 = (String) map84124.get("key84124"); // get it back out - String d84124 = c84124.substring(0, c84124.length() - 1); // extract most of it - String e84124 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d84124.getBytes()))); // B64 encode and decode it - String f84124 = e84124.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g84124 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g84124); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01516.java b/OWASP DATASET CLEANED/BenchmarkTest01516.java deleted file mode 100644 index a2e6b0378a1d5dd8063f89a67de149ee16279b24..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01516.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01516") -public class BenchmarkTest01516 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01516"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a84214 = param; // assign - StringBuilder b84214 = new StringBuilder(a84214); // stick in stringbuilder - b84214.append(" SafeStuff"); // append some safe content - b84214.replace( - b84214.length() - "Chars".length(), - b84214.length(), - "Chars"); // replace some of the end content - java.util.HashMap map84214 = new java.util.HashMap(); - map84214.put("key84214", b84214.toString()); // put in a collection - String c84214 = (String) map84214.get("key84214"); // get it back out - String d84214 = c84214.substring(0, c84214.length() - 1); // extract most of it - String e84214 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d84214.getBytes()))); // B64 encode and decode it - String f84214 = e84214.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g84214 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g84214); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01517.java b/OWASP DATASET CLEANED/BenchmarkTest01517.java deleted file mode 100644 index b124447841f29513ddc9a30ce46671187feda79e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01517.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01517") -public class BenchmarkTest01517 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01517"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01518.java b/OWASP DATASET CLEANED/BenchmarkTest01518.java deleted file mode 100644 index 4097b14184d24598e7d8630575cfbe7c701b6943..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01518.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01518") -public class BenchmarkTest01518 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01518"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a96602 = param; // assign - StringBuilder b96602 = new StringBuilder(a96602); // stick in stringbuilder - b96602.append(" SafeStuff"); // append some safe content - b96602.replace( - b96602.length() - "Chars".length(), - b96602.length(), - "Chars"); // replace some of the end content - java.util.HashMap map96602 = new java.util.HashMap(); - map96602.put("key96602", b96602.toString()); // put in a collection - String c96602 = (String) map96602.get("key96602"); // get it back out - String d96602 = c96602.substring(0, c96602.length() - 1); // extract most of it - String e96602 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d96602.getBytes()))); // B64 encode and decode it - String f96602 = e96602.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f96602); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01519.java b/OWASP DATASET CLEANED/BenchmarkTest01519.java deleted file mode 100644 index fe256911cae0ce46d7ed1a1ceeeb6f1444bfef0a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01519.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01519") -public class BenchmarkTest01519 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01519"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz3774 = new StringBuilder(param); - bar = - sbxyz3774 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01520.java b/OWASP DATASET CLEANED/BenchmarkTest01520.java deleted file mode 100644 index 57b6ba72570d384433656d099eb12a347a21d63a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01520.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01520") -public class BenchmarkTest01520 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01520"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map44642 = new java.util.HashMap(); - map44642.put("keyA-44642", "a_Value"); // put some stuff in the collection - map44642.put("keyB-44642", param); // put it in a collection - map44642.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map44642.get("keyB-44642"); // get it back out - bar = (String) map44642.get("keyA-44642"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01521.java b/OWASP DATASET CLEANED/BenchmarkTest01521.java deleted file mode 100644 index a1cf8dffb7ed9c908f2529d52838ab45023be060..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01521.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01521") -public class BenchmarkTest01521 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01521"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01522.java b/OWASP DATASET CLEANED/BenchmarkTest01522.java deleted file mode 100644 index 5a51cb0968c41f7f1030bc0f3dfd830a6f629d29..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01522.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01522") -public class BenchmarkTest01522 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01522"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01523.java b/OWASP DATASET CLEANED/BenchmarkTest01523.java deleted file mode 100644 index 7fadf45801c74c04f3fbadf39693a1415f82f858..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01523.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01523") -public class BenchmarkTest01523 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01523"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a94015 = param; // assign - StringBuilder b94015 = new StringBuilder(a94015); // stick in stringbuilder - b94015.append(" SafeStuff"); // append some safe content - b94015.replace( - b94015.length() - "Chars".length(), - b94015.length(), - "Chars"); // replace some of the end content - java.util.HashMap map94015 = new java.util.HashMap(); - map94015.put("key94015", b94015.toString()); // put in a collection - String c94015 = (String) map94015.get("key94015"); // get it back out - String d94015 = c94015.substring(0, c94015.length() - 1); // extract most of it - String e94015 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d94015.getBytes()))); // B64 encode and decode it - String f94015 = e94015.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f94015); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01524.java b/OWASP DATASET CLEANED/BenchmarkTest01524.java deleted file mode 100644 index 8585561b4e152118667ca1a082f1081386830976..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01524.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01524") -public class BenchmarkTest01524 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01524"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01525.java b/OWASP DATASET CLEANED/BenchmarkTest01525.java deleted file mode 100644 index 16536752f1fac8b735fce53c11303c87caf7328e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01525.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01525") -public class BenchmarkTest01525 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01525"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz67457 = new StringBuilder(param); - bar = - sbxyz67457 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01526.java b/OWASP DATASET CLEANED/BenchmarkTest01526.java deleted file mode 100644 index 2729d36f23d96fe4085155d5019e3072313cb222..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01526.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01526") -public class BenchmarkTest01526 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01526"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01527.java b/OWASP DATASET CLEANED/BenchmarkTest01527.java deleted file mode 100644 index eb61f30fe9fc60f4f9bcf3321baa8235c7ce3e02..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01527.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01527") -public class BenchmarkTest01527 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01527"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01528.java b/OWASP DATASET CLEANED/BenchmarkTest01528.java deleted file mode 100644 index cd75f47edea3e0041686af96135e73554d008070..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01528.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01528") -public class BenchmarkTest01528 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01528"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01529.java b/OWASP DATASET CLEANED/BenchmarkTest01529.java deleted file mode 100644 index f4b233fd965e1b02063aa913a3c42e57681bc46d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01529.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01529") -public class BenchmarkTest01529 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01529"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01530.java b/OWASP DATASET CLEANED/BenchmarkTest01530.java deleted file mode 100644 index 6a8479e24a87c9e798bcdca8235c554d23dfe99f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01530.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01530") -public class BenchmarkTest01530 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01530"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01531.java b/OWASP DATASET CLEANED/BenchmarkTest01531.java deleted file mode 100644 index 5b2570c9806a6f38b6b09880b403f77952136bdd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01531.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01531") -public class BenchmarkTest01531 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01531"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01532.java b/OWASP DATASET CLEANED/BenchmarkTest01532.java deleted file mode 100644 index d2b4b5cb43aa99ba0f904640b4c01669c1c370ad..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01532.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01532") -public class BenchmarkTest01532 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01532"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01533.java b/OWASP DATASET CLEANED/BenchmarkTest01533.java deleted file mode 100644 index a3c6becdf5484e4b09e3eb7ed59d752f9984d047..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01533.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01533") -public class BenchmarkTest01533 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01533"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01534.java b/OWASP DATASET CLEANED/BenchmarkTest01534.java deleted file mode 100644 index d5d4a8ba5eb45bd1f7778b618eaed3e518b0cb5a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01534.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01534") -public class BenchmarkTest01534 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01534"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01535.java b/OWASP DATASET CLEANED/BenchmarkTest01535.java deleted file mode 100644 index 881ee42cb84ae830487a65f4b55534f17bd254ee..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01535.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01535") -public class BenchmarkTest01535 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01535"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01536.java b/OWASP DATASET CLEANED/BenchmarkTest01536.java deleted file mode 100644 index 24bb15931940e0f6d8d5b479c6fc362baa0fa58a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01536.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01536") -public class BenchmarkTest01536 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01536"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a79311 = param; // assign - StringBuilder b79311 = new StringBuilder(a79311); // stick in stringbuilder - b79311.append(" SafeStuff"); // append some safe content - b79311.replace( - b79311.length() - "Chars".length(), - b79311.length(), - "Chars"); // replace some of the end content - java.util.HashMap map79311 = new java.util.HashMap(); - map79311.put("key79311", b79311.toString()); // put in a collection - String c79311 = (String) map79311.get("key79311"); // get it back out - String d79311 = c79311.substring(0, c79311.length() - 1); // extract most of it - String e79311 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d79311.getBytes()))); // B64 encode and decode it - String f79311 = e79311.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g79311 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g79311); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01537.java b/OWASP DATASET CLEANED/BenchmarkTest01537.java deleted file mode 100644 index 6435142f33cc20038326de1124e991cbd83f08bf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01537.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01537") -public class BenchmarkTest01537 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01537"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map7472 = new java.util.HashMap(); - map7472.put("keyA-7472", "a_Value"); // put some stuff in the collection - map7472.put("keyB-7472", param); // put it in a collection - map7472.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map7472.get("keyB-7472"); // get it back out - bar = (String) map7472.get("keyA-7472"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01538.java b/OWASP DATASET CLEANED/BenchmarkTest01538.java deleted file mode 100644 index d48c5df526b0cb7adc7e01fbf3e05f5bf11d4728..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01538.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01538") -public class BenchmarkTest01538 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01538"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map82396 = new java.util.HashMap(); - map82396.put("keyA-82396", "a_Value"); // put some stuff in the collection - map82396.put("keyB-82396", param); // put it in a collection - map82396.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map82396.get("keyB-82396"); // get it back out - bar = (String) map82396.get("keyA-82396"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01539.java b/OWASP DATASET CLEANED/BenchmarkTest01539.java deleted file mode 100644 index 6bcaf78e3db9b50b7c4ceaf7cace27d2f6fe56f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01539.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01539") -public class BenchmarkTest01539 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01539"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01540.java b/OWASP DATASET CLEANED/BenchmarkTest01540.java deleted file mode 100644 index 7b8066898ffc05bb0c320419a24d5488fc2a5468..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01540.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01540") -public class BenchmarkTest01540 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01540"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01541.java b/OWASP DATASET CLEANED/BenchmarkTest01541.java deleted file mode 100644 index 0dd4cbf8e06644db204411fd3fa64d70b46efbcc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01541.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01541") -public class BenchmarkTest01541 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01541"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01542.java b/OWASP DATASET CLEANED/BenchmarkTest01542.java deleted file mode 100644 index 140a3a73d06ce1191921357336dec866e45abc60..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01542.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01542") -public class BenchmarkTest01542 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01542"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map98601 = new java.util.HashMap(); - map98601.put("keyA-98601", "a-Value"); // put some stuff in the collection - map98601.put("keyB-98601", param); // put it in a collection - map98601.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map98601.get("keyB-98601"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01543.java b/OWASP DATASET CLEANED/BenchmarkTest01543.java deleted file mode 100644 index 8b8b786aad487d641461c2a5ce1f33e2bc9dc08b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01543.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01543") -public class BenchmarkTest01543 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01543"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01544.java b/OWASP DATASET CLEANED/BenchmarkTest01544.java deleted file mode 100644 index 1184c05e45c42b7080439c388f8a5de0e2147814..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01544.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01544") -public class BenchmarkTest01544 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01544"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01545.java b/OWASP DATASET CLEANED/BenchmarkTest01545.java deleted file mode 100644 index a7dc79b6c630f5099ea3d1ef88e5c051e10a04c3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01545.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01545") -public class BenchmarkTest01545 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01545"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a43050 = param; // assign - StringBuilder b43050 = new StringBuilder(a43050); // stick in stringbuilder - b43050.append(" SafeStuff"); // append some safe content - b43050.replace( - b43050.length() - "Chars".length(), - b43050.length(), - "Chars"); // replace some of the end content - java.util.HashMap map43050 = new java.util.HashMap(); - map43050.put("key43050", b43050.toString()); // put in a collection - String c43050 = (String) map43050.get("key43050"); // get it back out - String d43050 = c43050.substring(0, c43050.length() - 1); // extract most of it - String e43050 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d43050.getBytes()))); // B64 encode and decode it - String f43050 = e43050.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g43050 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g43050); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01546.java b/OWASP DATASET CLEANED/BenchmarkTest01546.java deleted file mode 100644 index 1b8243836c61556fdbf94dd7f215bba3c37865cc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01546.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01546") -public class BenchmarkTest01546 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01546"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01547.java b/OWASP DATASET CLEANED/BenchmarkTest01547.java deleted file mode 100644 index 0f65c868d2cfba15cdfc00d9cbb0d6fc9bf1908d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01547.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01547") -public class BenchmarkTest01547 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01547"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01548.java b/OWASP DATASET CLEANED/BenchmarkTest01548.java deleted file mode 100644 index 769cf550a687ced421b51c27d386bffc2681cc19..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01548.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01548") -public class BenchmarkTest01548 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01548"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01549.java b/OWASP DATASET CLEANED/BenchmarkTest01549.java deleted file mode 100644 index 9b2d37ede25f2ef5b471b94cafc7c6d7d80791a5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01549.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01549") -public class BenchmarkTest01549 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01549"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01550.java b/OWASP DATASET CLEANED/BenchmarkTest01550.java deleted file mode 100644 index fe16a35b43c954c3017a13e71865058284d0be1f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01550.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01550") -public class BenchmarkTest01550 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01550"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a86153 = param; // assign - StringBuilder b86153 = new StringBuilder(a86153); // stick in stringbuilder - b86153.append(" SafeStuff"); // append some safe content - b86153.replace( - b86153.length() - "Chars".length(), - b86153.length(), - "Chars"); // replace some of the end content - java.util.HashMap map86153 = new java.util.HashMap(); - map86153.put("key86153", b86153.toString()); // put in a collection - String c86153 = (String) map86153.get("key86153"); // get it back out - String d86153 = c86153.substring(0, c86153.length() - 1); // extract most of it - String e86153 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d86153.getBytes()))); // B64 encode and decode it - String f86153 = e86153.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f86153); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01551.java b/OWASP DATASET CLEANED/BenchmarkTest01551.java deleted file mode 100644 index 8506efe4793b1b1750aa87cf44f9c93f8431b36f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01551.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01551") -public class BenchmarkTest01551 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01551"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz68516 = new StringBuilder(param); - String bar = sbxyz68516.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01552.java b/OWASP DATASET CLEANED/BenchmarkTest01552.java deleted file mode 100644 index 30ccfb20b54ce67bad7d9586fc2d52ad40938044..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01552.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01552") -public class BenchmarkTest01552 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01552"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01553.java b/OWASP DATASET CLEANED/BenchmarkTest01553.java deleted file mode 100644 index 6299667bc806eaac3236b66a74edf21b4753d8b6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01553.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01553") -public class BenchmarkTest01553 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01553"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map99501 = new java.util.HashMap(); - map99501.put("keyA-99501", "a_Value"); // put some stuff in the collection - map99501.put("keyB-99501", param); // put it in a collection - map99501.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map99501.get("keyB-99501"); // get it back out - bar = (String) map99501.get("keyA-99501"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01554.java b/OWASP DATASET CLEANED/BenchmarkTest01554.java deleted file mode 100644 index 98f41ac9b11edf27aa57ab57bb0ada5eac2e6614..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01554.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01554") -public class BenchmarkTest01554 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01554"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01555.java b/OWASP DATASET CLEANED/BenchmarkTest01555.java deleted file mode 100644 index 0c43ca1843dd58111e8888212e01ea425bae4957..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01555.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01555") -public class BenchmarkTest01555 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01555"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01556.java b/OWASP DATASET CLEANED/BenchmarkTest01556.java deleted file mode 100644 index ca2835dc1d45c08efc45501dbdb806e809dbd396..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01556.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01556") -public class BenchmarkTest01556 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01556"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01557.java b/OWASP DATASET CLEANED/BenchmarkTest01557.java deleted file mode 100644 index 3143d858e083792168227b8762cce0e0601d5677..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01557.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01557") -public class BenchmarkTest01557 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01557"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map20581 = new java.util.HashMap(); - map20581.put("keyA-20581", "a-Value"); // put some stuff in the collection - map20581.put("keyB-20581", param); // put it in a collection - map20581.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map20581.get("keyB-20581"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01558.java b/OWASP DATASET CLEANED/BenchmarkTest01558.java deleted file mode 100644 index eb4cf5867dbfe25ccee6dc272fd66f4a3e2e3bda..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01558.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01558") -public class BenchmarkTest01558 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01558"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01559.java b/OWASP DATASET CLEANED/BenchmarkTest01559.java deleted file mode 100644 index d0ca5455325d597bc34b1d9156809dd847876681..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01559.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01559") -public class BenchmarkTest01559 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01559"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map31651 = new java.util.HashMap(); - map31651.put("keyA-31651", "a-Value"); // put some stuff in the collection - map31651.put("keyB-31651", param); // put it in a collection - map31651.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map31651.get("keyB-31651"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01560.java b/OWASP DATASET CLEANED/BenchmarkTest01560.java deleted file mode 100644 index 48217e41fd953b8adfc69a9ad9b1b002b07fb31a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01560.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01560") -public class BenchmarkTest01560 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01560"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01561.java b/OWASP DATASET CLEANED/BenchmarkTest01561.java deleted file mode 100644 index 664ab9d7c5c7e1476a63cfcabfba932dee730f4f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01561.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01561") -public class BenchmarkTest01561 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01561"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01562.java b/OWASP DATASET CLEANED/BenchmarkTest01562.java deleted file mode 100644 index d9ba071a673f7bb9e16f45b72151eed8048abf75..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01562.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01562") -public class BenchmarkTest01562 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest01562"); - if (param == null) param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01563.java b/OWASP DATASET CLEANED/BenchmarkTest01563.java deleted file mode 100644 index dbed079f1e024dba58cf39d43b762ba1e4d2bb40..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01563.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01563") -public class BenchmarkTest01563 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01563"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01564.java b/OWASP DATASET CLEANED/BenchmarkTest01564.java deleted file mode 100644 index e0e9b38e43b7fe04668153ed69c51fd5fb6e296f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01564.java +++ /dev/null @@ -1,162 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01564") -public class BenchmarkTest01564 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01564"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01565.java b/OWASP DATASET CLEANED/BenchmarkTest01565.java deleted file mode 100644 index 14111bee44de0281cb9f29ef4035d21a4d84359b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01565.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01565") -public class BenchmarkTest01565 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01565"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01566.java b/OWASP DATASET CLEANED/BenchmarkTest01566.java deleted file mode 100644 index ca97e13fe2f0028902fbb14df1a8fc725c657ab8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01566.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01566") -public class BenchmarkTest01566 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01566"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01567.java b/OWASP DATASET CLEANED/BenchmarkTest01567.java deleted file mode 100644 index 4d7f35561676fc62375ae570d59c3052894d7cb6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01567.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-01/BenchmarkTest01567") -public class BenchmarkTest01567 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01567"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a29366 = param; // assign - StringBuilder b29366 = new StringBuilder(a29366); // stick in stringbuilder - b29366.append(" SafeStuff"); // append some safe content - b29366.replace( - b29366.length() - "Chars".length(), - b29366.length(), - "Chars"); // replace some of the end content - java.util.HashMap map29366 = new java.util.HashMap(); - map29366.put("key29366", b29366.toString()); // put in a collection - String c29366 = (String) map29366.get("key29366"); // get it back out - String d29366 = c29366.substring(0, c29366.length() - 1); // extract most of it - String e29366 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d29366.getBytes()))); // B64 encode and decode it - String f29366 = e29366.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g29366 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g29366); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01568.java b/OWASP DATASET CLEANED/BenchmarkTest01568.java deleted file mode 100644 index c9d7b9b9a0c63aa1a5f5af88d9e5372414e43127..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01568.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01568") -public class BenchmarkTest01568 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01568"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01569.java b/OWASP DATASET CLEANED/BenchmarkTest01569.java deleted file mode 100644 index 40c20e8ad2b8334552754fe668e57991794ba285..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01569.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01569") -public class BenchmarkTest01569 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01569"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a75250 = param; // assign - StringBuilder b75250 = new StringBuilder(a75250); // stick in stringbuilder - b75250.append(" SafeStuff"); // append some safe content - b75250.replace( - b75250.length() - "Chars".length(), - b75250.length(), - "Chars"); // replace some of the end content - java.util.HashMap map75250 = new java.util.HashMap(); - map75250.put("key75250", b75250.toString()); // put in a collection - String c75250 = (String) map75250.get("key75250"); // get it back out - String d75250 = c75250.substring(0, c75250.length() - 1); // extract most of it - String e75250 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d75250.getBytes()))); // B64 encode and decode it - String f75250 = e75250.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g75250 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g75250); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01570.java b/OWASP DATASET CLEANED/BenchmarkTest01570.java deleted file mode 100644 index 9ec7d6b474a8abb641a4db2138237cc6e1258312..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01570.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01570") -public class BenchmarkTest01570 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01570"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01571.java b/OWASP DATASET CLEANED/BenchmarkTest01571.java deleted file mode 100644 index 19091f2c6c806af4e157b1e9ecf79819e8a75b12..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01571.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01571") -public class BenchmarkTest01571 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01571"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01572.java b/OWASP DATASET CLEANED/BenchmarkTest01572.java deleted file mode 100644 index 79f8f50c9b258aa4834a1698a3041bd01284e326..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01572.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01572") -public class BenchmarkTest01572 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01572"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01573.java b/OWASP DATASET CLEANED/BenchmarkTest01573.java deleted file mode 100644 index 498b2c1fae7ca637786598085fb01a223d36e672..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01573.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01573") -public class BenchmarkTest01573 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01573"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01574.java b/OWASP DATASET CLEANED/BenchmarkTest01574.java deleted file mode 100644 index 251ef4e2c9580688d2fb6a87bb68ccdf59c9052d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01574.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01574") -public class BenchmarkTest01574 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01574"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map48244 = new java.util.HashMap(); - map48244.put("keyA-48244", "a_Value"); // put some stuff in the collection - map48244.put("keyB-48244", param); // put it in a collection - map48244.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map48244.get("keyB-48244"); // get it back out - bar = (String) map48244.get("keyA-48244"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01575.java b/OWASP DATASET CLEANED/BenchmarkTest01575.java deleted file mode 100644 index 5804e928c8c04fa210b842ca569b22bdfaeca04c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01575.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01575") -public class BenchmarkTest01575 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01575"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01576.java b/OWASP DATASET CLEANED/BenchmarkTest01576.java deleted file mode 100644 index 4030f46a30cf5e281c076084e7b73bc5095e536a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01576.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01576") -public class BenchmarkTest01576 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01576"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01577.java b/OWASP DATASET CLEANED/BenchmarkTest01577.java deleted file mode 100644 index 7389cf35a45aa11dc48a4880e68f0b115fad1bcf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01577.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01577") -public class BenchmarkTest01577 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01577"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01578.java b/OWASP DATASET CLEANED/BenchmarkTest01578.java deleted file mode 100644 index 1e9253b514a9869bfbdc546c0c26a5a88c4cf8d7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01578.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01578") -public class BenchmarkTest01578 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01578"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz85952 = new StringBuilder(param); - String bar = sbxyz85952.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01579.java b/OWASP DATASET CLEANED/BenchmarkTest01579.java deleted file mode 100644 index 33587507ac1cfe738298f68c2074244e57a52e61..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01579.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01579") -public class BenchmarkTest01579 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01579"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01580.java b/OWASP DATASET CLEANED/BenchmarkTest01580.java deleted file mode 100644 index c8d26125dfd7deceaace7521a811ce24799edb57..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01580.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01580") -public class BenchmarkTest01580 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01580"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01581.java b/OWASP DATASET CLEANED/BenchmarkTest01581.java deleted file mode 100644 index cc1de5a27cafc1b3accbb7af22c49796f68c75d6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01581.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01581") -public class BenchmarkTest01581 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01581"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01582.java b/OWASP DATASET CLEANED/BenchmarkTest01582.java deleted file mode 100644 index 32b2cc26ee0842328fc8b2f565d150a80d30166c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01582.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01582") -public class BenchmarkTest01582 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01582"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map17367 = new java.util.HashMap(); - map17367.put("keyA-17367", "a_Value"); // put some stuff in the collection - map17367.put("keyB-17367", param); // put it in a collection - map17367.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map17367.get("keyB-17367"); // get it back out - bar = (String) map17367.get("keyA-17367"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01583.java b/OWASP DATASET CLEANED/BenchmarkTest01583.java deleted file mode 100644 index a0fe85e01c22dba6b3486c9d84a475f0448cfd5a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01583.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01583") -public class BenchmarkTest01583 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01583"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz82559 = new StringBuilder(param); - String bar = sbxyz82559.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01584.java b/OWASP DATASET CLEANED/BenchmarkTest01584.java deleted file mode 100644 index 1941206e213c527cef583aca5f435dcc1b27bec7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01584.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01584") -public class BenchmarkTest01584 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01584"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01585.java b/OWASP DATASET CLEANED/BenchmarkTest01585.java deleted file mode 100644 index 8e3a9a3dab58751e5ee058d2b4dc6ceaf7cc63a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01585.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01585") -public class BenchmarkTest01585 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01585"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01586.java b/OWASP DATASET CLEANED/BenchmarkTest01586.java deleted file mode 100644 index 386c7e5d0cd835230d3401e74c50785eb202c7c7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01586.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01586") -public class BenchmarkTest01586 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01586"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01587.java b/OWASP DATASET CLEANED/BenchmarkTest01587.java deleted file mode 100644 index 50beeef8ce5c345d503b42d77d3e98ddfdd0a992..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01587.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01587") -public class BenchmarkTest01587 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01587"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01588.java b/OWASP DATASET CLEANED/BenchmarkTest01588.java deleted file mode 100644 index 42091d4f2002c9c63b917d5e10f20c4240c2b74e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01588.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01588") -public class BenchmarkTest01588 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01588"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01589.java b/OWASP DATASET CLEANED/BenchmarkTest01589.java deleted file mode 100644 index 07771df8a46427d2b78984fdf5c80ba76e36981c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01589.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01589") -public class BenchmarkTest01589 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01589"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01590.java b/OWASP DATASET CLEANED/BenchmarkTest01590.java deleted file mode 100644 index 406223b79f669a12c58f981148fb442a28cdc88e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01590.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01590") -public class BenchmarkTest01590 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01590"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01591.java b/OWASP DATASET CLEANED/BenchmarkTest01591.java deleted file mode 100644 index 46af59ae587597510416f091a45c029c02006820..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01591.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01591") -public class BenchmarkTest01591 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01591"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a1207 = param; // assign - StringBuilder b1207 = new StringBuilder(a1207); // stick in stringbuilder - b1207.append(" SafeStuff"); // append some safe content - b1207.replace( - b1207.length() - "Chars".length(), - b1207.length(), - "Chars"); // replace some of the end content - java.util.HashMap map1207 = new java.util.HashMap(); - map1207.put("key1207", b1207.toString()); // put in a collection - String c1207 = (String) map1207.get("key1207"); // get it back out - String d1207 = c1207.substring(0, c1207.length() - 1); // extract most of it - String e1207 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d1207.getBytes()))); // B64 encode and decode it - String f1207 = e1207.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g1207 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g1207); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01592.java b/OWASP DATASET CLEANED/BenchmarkTest01592.java deleted file mode 100644 index 136cd1ba69545d32017a59fb7f5034eb959b1d7f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01592.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01592") -public class BenchmarkTest01592 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01592"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01593.java b/OWASP DATASET CLEANED/BenchmarkTest01593.java deleted file mode 100644 index abd49d3f62af7c1da51c965a6c5206eea8ede526..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01593.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01593") -public class BenchmarkTest01593 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01593"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01594.java b/OWASP DATASET CLEANED/BenchmarkTest01594.java deleted file mode 100644 index 586336579a11121bce16b48f9627e2ead315f438..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01594.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01594") -public class BenchmarkTest01594 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01594"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz51154 = new StringBuilder(param); - String bar = sbxyz51154.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01595.java b/OWASP DATASET CLEANED/BenchmarkTest01595.java deleted file mode 100644 index 4283e7fb90a06af3ed334d9406975e9a5ea6352d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01595.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01595") -public class BenchmarkTest01595 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01595"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01596.java b/OWASP DATASET CLEANED/BenchmarkTest01596.java deleted file mode 100644 index 736c0f20b98aba439fb7bf6b65ec23dc87a2a730..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01596.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01596") -public class BenchmarkTest01596 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01596"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01597.java b/OWASP DATASET CLEANED/BenchmarkTest01597.java deleted file mode 100644 index 79d61a81f4b116132070c3451956e0cf1415bf0f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01597.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01597") -public class BenchmarkTest01597 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01597"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz81751 = new StringBuilder(param); - String bar = sbxyz81751.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01598.java b/OWASP DATASET CLEANED/BenchmarkTest01598.java deleted file mode 100644 index c88251bf9efaff6e3a9724ebf598895b33490ed2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01598.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01598") -public class BenchmarkTest01598 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01598"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a75770 = param; // assign - StringBuilder b75770 = new StringBuilder(a75770); // stick in stringbuilder - b75770.append(" SafeStuff"); // append some safe content - b75770.replace( - b75770.length() - "Chars".length(), - b75770.length(), - "Chars"); // replace some of the end content - java.util.HashMap map75770 = new java.util.HashMap(); - map75770.put("key75770", b75770.toString()); // put in a collection - String c75770 = (String) map75770.get("key75770"); // get it back out - String d75770 = c75770.substring(0, c75770.length() - 1); // extract most of it - String e75770 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d75770.getBytes()))); // B64 encode and decode it - String f75770 = e75770.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f75770); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01599.java b/OWASP DATASET CLEANED/BenchmarkTest01599.java deleted file mode 100644 index 0f2714b17314f6dcb4deb76165c659b84d7fa920..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01599.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01599") -public class BenchmarkTest01599 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01599"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map20521 = new java.util.HashMap(); - map20521.put("keyA-20521", "a_Value"); // put some stuff in the collection - map20521.put("keyB-20521", param); // put it in a collection - map20521.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map20521.get("keyB-20521"); // get it back out - bar = (String) map20521.get("keyA-20521"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01600.java b/OWASP DATASET CLEANED/BenchmarkTest01600.java deleted file mode 100644 index 53413c78d68c9c6e3c8afc7bf2f32992152639f3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01600.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01600") -public class BenchmarkTest01600 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01600"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01601.java b/OWASP DATASET CLEANED/BenchmarkTest01601.java deleted file mode 100644 index fadb647a75e0c7e2281765d63c0113ee8bac0e29..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01601.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01601") -public class BenchmarkTest01601 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01601"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01602.java b/OWASP DATASET CLEANED/BenchmarkTest01602.java deleted file mode 100644 index 8d663799eda3aae17c5fb1a38a37aa3bf37354dd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01602.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01602") -public class BenchmarkTest01602 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01602"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01603.java b/OWASP DATASET CLEANED/BenchmarkTest01603.java deleted file mode 100644 index bff532c8a9bee997f85448fc74cde6e9ddeb6c3a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01603.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01603") -public class BenchmarkTest01603 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01603"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a74856 = param; // assign - StringBuilder b74856 = new StringBuilder(a74856); // stick in stringbuilder - b74856.append(" SafeStuff"); // append some safe content - b74856.replace( - b74856.length() - "Chars".length(), - b74856.length(), - "Chars"); // replace some of the end content - java.util.HashMap map74856 = new java.util.HashMap(); - map74856.put("key74856", b74856.toString()); // put in a collection - String c74856 = (String) map74856.get("key74856"); // get it back out - String d74856 = c74856.substring(0, c74856.length() - 1); // extract most of it - String e74856 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d74856.getBytes()))); // B64 encode and decode it - String f74856 = e74856.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g74856 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g74856); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01604.java b/OWASP DATASET CLEANED/BenchmarkTest01604.java deleted file mode 100644 index 632207870fe4ae4e98f2e2cc8e610d398903ffd9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01604.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01604") -public class BenchmarkTest01604 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01604"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01605.java b/OWASP DATASET CLEANED/BenchmarkTest01605.java deleted file mode 100644 index 6ca8fc526a3f101d77f3dd0dd3350bab6f0d1e72..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01605.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01605") -public class BenchmarkTest01605 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01605"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map97880 = new java.util.HashMap(); - map97880.put("keyA-97880", "a_Value"); // put some stuff in the collection - map97880.put("keyB-97880", param); // put it in a collection - map97880.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map97880.get("keyB-97880"); // get it back out - bar = (String) map97880.get("keyA-97880"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01606.java b/OWASP DATASET CLEANED/BenchmarkTest01606.java deleted file mode 100644 index 3b89e42a214d66ce8ed0a76a34acd10feb22b4bd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01606.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01606") -public class BenchmarkTest01606 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01606"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01607.java b/OWASP DATASET CLEANED/BenchmarkTest01607.java deleted file mode 100644 index 0c2cf7dc8b746751016e09d8c523a7aaa487af01..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01607.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01607") -public class BenchmarkTest01607 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01607"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01608.java b/OWASP DATASET CLEANED/BenchmarkTest01608.java deleted file mode 100644 index 3b93bc4ae594e5ca41178b5c74b9793064f094f7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01608.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01608") -public class BenchmarkTest01608 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01608"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map55872 = new java.util.HashMap(); - map55872.put("keyA-55872", "a_Value"); // put some stuff in the collection - map55872.put("keyB-55872", param); // put it in a collection - map55872.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map55872.get("keyB-55872"); // get it back out - bar = (String) map55872.get("keyA-55872"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01609.java b/OWASP DATASET CLEANED/BenchmarkTest01609.java deleted file mode 100644 index 8fe6ff86ea2f8f4ea8b117b7b6238bc76f8df504..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01609.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01609") -public class BenchmarkTest01609 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01609"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01610.java b/OWASP DATASET CLEANED/BenchmarkTest01610.java deleted file mode 100644 index 6178cb93a1f4fd3c08be0d8fdbcfdea635e38977..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01610.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01610") -public class BenchmarkTest01610 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01610"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01611.java b/OWASP DATASET CLEANED/BenchmarkTest01611.java deleted file mode 100644 index 7aa5459a7977cf72edc75b128a8d89266a372f2c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01611.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01611") -public class BenchmarkTest01611 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01611"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01612.java b/OWASP DATASET CLEANED/BenchmarkTest01612.java deleted file mode 100644 index 9f0bdb72652f858a58164814a87030d90de0bf09..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01612.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01612") -public class BenchmarkTest01612 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01612"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01613.java b/OWASP DATASET CLEANED/BenchmarkTest01613.java deleted file mode 100644 index 4b401f3f9798b6bcd2329eb2d9df72dba072f632..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01613.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01613") -public class BenchmarkTest01613 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01613"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01614.java b/OWASP DATASET CLEANED/BenchmarkTest01614.java deleted file mode 100644 index f35a34bed8d595fdb299304b32a5783773d94b91..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01614.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01614") -public class BenchmarkTest01614 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01614"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01615.java b/OWASP DATASET CLEANED/BenchmarkTest01615.java deleted file mode 100644 index 3d2aae6925b97e26407ffcff05b7fa0ff6867973..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01615.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01615") -public class BenchmarkTest01615 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01615"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz57216 = new StringBuilder(param); - bar = - sbxyz57216 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01616.java b/OWASP DATASET CLEANED/BenchmarkTest01616.java deleted file mode 100644 index 3f6aa528038817df8dd7f3a0be7d5b3c5e9082b9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01616.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01616") -public class BenchmarkTest01616 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01616"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a53857 = param; // assign - StringBuilder b53857 = new StringBuilder(a53857); // stick in stringbuilder - b53857.append(" SafeStuff"); // append some safe content - b53857.replace( - b53857.length() - "Chars".length(), - b53857.length(), - "Chars"); // replace some of the end content - java.util.HashMap map53857 = new java.util.HashMap(); - map53857.put("key53857", b53857.toString()); // put in a collection - String c53857 = (String) map53857.get("key53857"); // get it back out - String d53857 = c53857.substring(0, c53857.length() - 1); // extract most of it - String e53857 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d53857.getBytes()))); // B64 encode and decode it - String f53857 = e53857.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f53857); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01617.java b/OWASP DATASET CLEANED/BenchmarkTest01617.java deleted file mode 100644 index c31d1f6e338553b3c3ddeafb3e6a02b2846e27d6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01617.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01617") -public class BenchmarkTest01617 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01617"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01618.java b/OWASP DATASET CLEANED/BenchmarkTest01618.java deleted file mode 100644 index 9a0fd89e8501c256233c7f66e1e51bff0d5826ab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01618.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-00/BenchmarkTest01618") -public class BenchmarkTest01618 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01618"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01619.java b/OWASP DATASET CLEANED/BenchmarkTest01619.java deleted file mode 100644 index 26193557ce0853ac49a4e4975980e009c205b129..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01619.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01619") -public class BenchmarkTest01619 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01619"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01620.java b/OWASP DATASET CLEANED/BenchmarkTest01620.java deleted file mode 100644 index 3c8f3ffba3128c07340e741420660008b2fc31ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01620.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01620") -public class BenchmarkTest01620 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01620"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01621.java b/OWASP DATASET CLEANED/BenchmarkTest01621.java deleted file mode 100644 index e157229422025eff134418984ca7789ea2571c5c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01621.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01621") -public class BenchmarkTest01621 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01621"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01622.java b/OWASP DATASET CLEANED/BenchmarkTest01622.java deleted file mode 100644 index 14f6c6b3386f86a10244d69688e03f82edc5b8d9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01622.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01622") -public class BenchmarkTest01622 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01622"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01623.java b/OWASP DATASET CLEANED/BenchmarkTest01623.java deleted file mode 100644 index 9a8cc61f26c9b55a906df19ccc45a0803a20eb38..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01623.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01623") -public class BenchmarkTest01623 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01623"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01624.java b/OWASP DATASET CLEANED/BenchmarkTest01624.java deleted file mode 100644 index da32c767da7278cba9770887c32ecea5dd26f6ae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01624.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01624") -public class BenchmarkTest01624 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01624"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01625.java b/OWASP DATASET CLEANED/BenchmarkTest01625.java deleted file mode 100644 index 322b6f2e1fba94dc34de1799dda75052df36c74f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01625.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01625") -public class BenchmarkTest01625 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01625"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01626.java b/OWASP DATASET CLEANED/BenchmarkTest01626.java deleted file mode 100644 index 1b9f0c32715bfc17f0b6e160f4278e6e66f14593..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01626.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01626") -public class BenchmarkTest01626 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01626"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01627.java b/OWASP DATASET CLEANED/BenchmarkTest01627.java deleted file mode 100644 index e94f0fe638aec57eb3ff751583370d34b466a06b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01627.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01627") -public class BenchmarkTest01627 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01627"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01628.java b/OWASP DATASET CLEANED/BenchmarkTest01628.java deleted file mode 100644 index 3cc4796614092ba5b95d215e7ba9ae7ec6ba394a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01628.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01628") -public class BenchmarkTest01628 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01628"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01629.java b/OWASP DATASET CLEANED/BenchmarkTest01629.java deleted file mode 100644 index 960f342be6cfaafb5cb335a060c1d339a60f63be..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01629.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01629") -public class BenchmarkTest01629 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01629"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01630.java b/OWASP DATASET CLEANED/BenchmarkTest01630.java deleted file mode 100644 index 25735ca49fb48577d7ccd6a0662a641d7a926980..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01630.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01630") -public class BenchmarkTest01630 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01630"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01631.java b/OWASP DATASET CLEANED/BenchmarkTest01631.java deleted file mode 100644 index 523623de6f2957273729b91f044a0a87f46b22f3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01631.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01631") -public class BenchmarkTest01631 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01631"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01632.java b/OWASP DATASET CLEANED/BenchmarkTest01632.java deleted file mode 100644 index e773bb157d12b828a93d7deb3b15f72aa9655d4e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01632.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01632") -public class BenchmarkTest01632 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01632"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01633.java b/OWASP DATASET CLEANED/BenchmarkTest01633.java deleted file mode 100644 index 35b1fef4e284db40f82618940b31ad5f96cf4f11..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01633.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01633") -public class BenchmarkTest01633 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest01633"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a31144 = param; // assign - StringBuilder b31144 = new StringBuilder(a31144); // stick in stringbuilder - b31144.append(" SafeStuff"); // append some safe content - b31144.replace( - b31144.length() - "Chars".length(), - b31144.length(), - "Chars"); // replace some of the end content - java.util.HashMap map31144 = new java.util.HashMap(); - map31144.put("key31144", b31144.toString()); // put in a collection - String c31144 = (String) map31144.get("key31144"); // get it back out - String d31144 = c31144.substring(0, c31144.length() - 1); // extract most of it - String e31144 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d31144.getBytes()))); // B64 encode and decode it - String f31144 = e31144.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g31144 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g31144); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01634.java b/OWASP DATASET CLEANED/BenchmarkTest01634.java deleted file mode 100644 index cd9787781d799a4327891ca05630a1b294df525f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01634.java +++ /dev/null @@ -1,204 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01634") -public class BenchmarkTest01634 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01634" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01634" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01634" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a37769 = param; // assign - StringBuilder b37769 = new StringBuilder(a37769); // stick in stringbuilder - b37769.append(" SafeStuff"); // append some safe content - b37769.replace( - b37769.length() - "Chars".length(), - b37769.length(), - "Chars"); // replace some of the end content - java.util.HashMap map37769 = new java.util.HashMap(); - map37769.put("key37769", b37769.toString()); // put in a collection - String c37769 = (String) map37769.get("key37769"); // get it back out - String d37769 = c37769.substring(0, c37769.length() - 1); // extract most of it - String e37769 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d37769.getBytes()))); // B64 encode and decode it - String f37769 = e37769.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g37769 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g37769); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01635.java b/OWASP DATASET CLEANED/BenchmarkTest01635.java deleted file mode 100644 index 7d084432c6a24a046cdfcc70118e7bd9b0c002e5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01635.java +++ /dev/null @@ -1,186 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01635") -public class BenchmarkTest01635 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01635" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01635" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01635" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01636.java b/OWASP DATASET CLEANED/BenchmarkTest01636.java deleted file mode 100644 index a320db7089c72914373a301c55fb1fad62838c88..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01636.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01636") -public class BenchmarkTest01636 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01636" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01636" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01636" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01637.java b/OWASP DATASET CLEANED/BenchmarkTest01637.java deleted file mode 100644 index 3cffab4551d44093ad24858f80a29993db569eab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01637.java +++ /dev/null @@ -1,206 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01637") -public class BenchmarkTest01637 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01637" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01637" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01637" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01638.java b/OWASP DATASET CLEANED/BenchmarkTest01638.java deleted file mode 100644 index 8865bed720d3a93975480c024bd540c6ad0cadbf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01638.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01638") -public class BenchmarkTest01638 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01638" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01638" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01638" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a61263 = param; // assign - StringBuilder b61263 = new StringBuilder(a61263); // stick in stringbuilder - b61263.append(" SafeStuff"); // append some safe content - b61263.replace( - b61263.length() - "Chars".length(), - b61263.length(), - "Chars"); // replace some of the end content - java.util.HashMap map61263 = new java.util.HashMap(); - map61263.put("key61263", b61263.toString()); // put in a collection - String c61263 = (String) map61263.get("key61263"); // get it back out - String d61263 = c61263.substring(0, c61263.length() - 1); // extract most of it - String e61263 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d61263.getBytes()))); // B64 encode and decode it - String f61263 = e61263.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f61263); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01639.java b/OWASP DATASET CLEANED/BenchmarkTest01639.java deleted file mode 100644 index d15e7861d343039442d68bddcf91acbb5265e51f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01639.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01639") -public class BenchmarkTest01639 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01639" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01639" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01639" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map62111 = new java.util.HashMap(); - map62111.put("keyA-62111", "a_Value"); // put some stuff in the collection - map62111.put("keyB-62111", param); // put it in a collection - map62111.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map62111.get("keyB-62111"); // get it back out - bar = (String) map62111.get("keyA-62111"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01640.java b/OWASP DATASET CLEANED/BenchmarkTest01640.java deleted file mode 100644 index 16b0adc1ea3ab06e326bf6ed213a6b35552ec0f1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01640.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01640") -public class BenchmarkTest01640 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01640" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01640" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01640" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01641.java b/OWASP DATASET CLEANED/BenchmarkTest01641.java deleted file mode 100644 index 8734d13c72d3f55f2b664f8703f136c4c669e554..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01641.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01641") -public class BenchmarkTest01641 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01641" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01641" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01641" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map5640 = new java.util.HashMap(); - map5640.put("keyA-5640", "a_Value"); // put some stuff in the collection - map5640.put("keyB-5640", param); // put it in a collection - map5640.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map5640.get("keyB-5640"); // get it back out - bar = (String) map5640.get("keyA-5640"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01642.java b/OWASP DATASET CLEANED/BenchmarkTest01642.java deleted file mode 100644 index 5eabe20ee33cbc07a4fd445b66e617b3abc6cb61..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01642.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01642") -public class BenchmarkTest01642 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01642" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01642" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01642" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01643.java b/OWASP DATASET CLEANED/BenchmarkTest01643.java deleted file mode 100644 index d3c196b45e07971cc232b461f3b5fbcc31f4456e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01643.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01643") -public class BenchmarkTest01643 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01643" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01643" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01643" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01644.java b/OWASP DATASET CLEANED/BenchmarkTest01644.java deleted file mode 100644 index 4d70ed8e6c9848295656f0c5f345e1ec209f81ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01644.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01644") -public class BenchmarkTest01644 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01644" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01644" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01644" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01645.java b/OWASP DATASET CLEANED/BenchmarkTest01645.java deleted file mode 100644 index 2dbb225aecbbb7f19db56eff1dd47660c47d6089..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01645.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01645") -public class BenchmarkTest01645 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01645" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01645" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01645" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01646.java b/OWASP DATASET CLEANED/BenchmarkTest01646.java deleted file mode 100644 index 47c9515b0607288b3f31c844b677e2e67fb44894..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01646.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-01/BenchmarkTest01646") -public class BenchmarkTest01646 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01646" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01646" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01646" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map84260 = new java.util.HashMap(); - map84260.put("keyA-84260", "a_Value"); // put some stuff in the collection - map84260.put("keyB-84260", param); // put it in a collection - map84260.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map84260.get("keyB-84260"); // get it back out - bar = (String) map84260.get("keyA-84260"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01647.java b/OWASP DATASET CLEANED/BenchmarkTest01647.java deleted file mode 100644 index 26b25122475b2bfa8dfaac7f1e4eee5209ac3c6b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01647.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01647") -public class BenchmarkTest01647 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01647" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01647" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01647" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01648.java b/OWASP DATASET CLEANED/BenchmarkTest01648.java deleted file mode 100644 index bed6b1e5f9c0d8e15f5fc59ce9034a3378c3c7c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01648.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01648") -public class BenchmarkTest01648 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01648" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01648" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01648" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01649.java b/OWASP DATASET CLEANED/BenchmarkTest01649.java deleted file mode 100644 index cc33d97520a9bcc180493fa81216ffc2367192bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01649.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01649") -public class BenchmarkTest01649 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01649" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01649" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01649" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map61654 = new java.util.HashMap(); - map61654.put("keyA-61654", "a_Value"); // put some stuff in the collection - map61654.put("keyB-61654", param); // put it in a collection - map61654.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map61654.get("keyB-61654"); // get it back out - bar = (String) map61654.get("keyA-61654"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01650.java b/OWASP DATASET CLEANED/BenchmarkTest01650.java deleted file mode 100644 index 72af3bb65a3e60b8d824833b279d51bcc7ac8390..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01650.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01650") -public class BenchmarkTest01650 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01650" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01650" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01650" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01651.java b/OWASP DATASET CLEANED/BenchmarkTest01651.java deleted file mode 100644 index 6f0ff06e2da2c19b594843e08d1af4f6d0eefec5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01651.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01651") -public class BenchmarkTest01651 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01651" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01651" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01651" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01652.java b/OWASP DATASET CLEANED/BenchmarkTest01652.java deleted file mode 100644 index 12035e275508ac349f7bf9c87376efcc265cee5c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01652.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01652") -public class BenchmarkTest01652 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01652" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01652" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01652" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map16429 = new java.util.HashMap(); - map16429.put("keyA-16429", "a_Value"); // put some stuff in the collection - map16429.put("keyB-16429", param); // put it in a collection - map16429.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map16429.get("keyB-16429"); // get it back out - bar = (String) map16429.get("keyA-16429"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01653.java b/OWASP DATASET CLEANED/BenchmarkTest01653.java deleted file mode 100644 index ed415422e30a4d9effa9f9552bd2c58902e8af97..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01653.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01653") -public class BenchmarkTest01653 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01653" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01653" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01653" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01654.java b/OWASP DATASET CLEANED/BenchmarkTest01654.java deleted file mode 100644 index 3657413053acd4eb3b7b37415d75337eb101fbf8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01654.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01654") -public class BenchmarkTest01654 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01654" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01654" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01654" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01655.java b/OWASP DATASET CLEANED/BenchmarkTest01655.java deleted file mode 100644 index b8fad12f2511c369841223045f3ad9557df54e17..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01655.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01655") -public class BenchmarkTest01655 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01655" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01655" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01655" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01656.java b/OWASP DATASET CLEANED/BenchmarkTest01656.java deleted file mode 100644 index fbbcc88fa335f8bb3bfa0cad1fc517c55a99e084..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01656.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01656") -public class BenchmarkTest01656 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01656" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01656" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01656" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01657.java b/OWASP DATASET CLEANED/BenchmarkTest01657.java deleted file mode 100644 index 525af1e7f0a10687900150383ccbb2de11e1f7a7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01657.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01657") -public class BenchmarkTest01657 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01657" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01657" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01657" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01658.java b/OWASP DATASET CLEANED/BenchmarkTest01658.java deleted file mode 100644 index 1d9cf59c87565772a92b62b44133d6eea971a8ab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01658.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01658") -public class BenchmarkTest01658 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01658" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01658" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01658" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01659.java b/OWASP DATASET CLEANED/BenchmarkTest01659.java deleted file mode 100644 index 7d7bf6089664d7077caf66cd5ab46dda0f8f4949..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01659.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01659") -public class BenchmarkTest01659 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01659" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01659" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01659" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01660.java b/OWASP DATASET CLEANED/BenchmarkTest01660.java deleted file mode 100644 index c5d51505a1c80cc9cbb11f4ac3ff4f4d9f02483d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01660.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01660") -public class BenchmarkTest01660 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01660" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01660" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01660" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01661.java b/OWASP DATASET CLEANED/BenchmarkTest01661.java deleted file mode 100644 index 14a0afdeb893ddde91ca39d3a7c81fefd7c5ed15..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01661.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01661") -public class BenchmarkTest01661 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01661" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01661" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01661" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01662.java b/OWASP DATASET CLEANED/BenchmarkTest01662.java deleted file mode 100644 index 73d1ec5d616f27a52780d734b7c0af5d45eb94c9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01662.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01662") -public class BenchmarkTest01662 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01662" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01662" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01662" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01663.java b/OWASP DATASET CLEANED/BenchmarkTest01663.java deleted file mode 100644 index 023ccebc52ceb665b3a2c8098b87a24a3d1989d8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01663.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01663") -public class BenchmarkTest01663 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01663" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01663" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01663" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map36601 = new java.util.HashMap(); - map36601.put("keyA-36601", "a_Value"); // put some stuff in the collection - map36601.put("keyB-36601", param); // put it in a collection - map36601.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map36601.get("keyB-36601"); // get it back out - bar = (String) map36601.get("keyA-36601"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01664.java b/OWASP DATASET CLEANED/BenchmarkTest01664.java deleted file mode 100644 index f7e69c8832cf3df14f8284486129c48833a973ca..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01664.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01664") -public class BenchmarkTest01664 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01664" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01664" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01664" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01665.java b/OWASP DATASET CLEANED/BenchmarkTest01665.java deleted file mode 100644 index 6748b4e55f2cfd216c6aa04c3718bbfe1f85dc16..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01665.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01665") -public class BenchmarkTest01665 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01665" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01665" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01665" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz55941 = new StringBuilder(param); - String bar = sbxyz55941.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01666.java b/OWASP DATASET CLEANED/BenchmarkTest01666.java deleted file mode 100644 index 89ac3fda7097e8bbb24b0d0f7afa2a9edff7ab2a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01666.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01666") -public class BenchmarkTest01666 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01666" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01666" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01666" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz41549 = new StringBuilder(param); - bar = - sbxyz41549 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01667.java b/OWASP DATASET CLEANED/BenchmarkTest01667.java deleted file mode 100644 index dad76355a09ea67b27e2bee9fcc44b902a0a2898..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01667.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01667") -public class BenchmarkTest01667 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01667" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01667" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01667" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map96771 = new java.util.HashMap(); - map96771.put("keyA-96771", "a-Value"); // put some stuff in the collection - map96771.put("keyB-96771", param); // put it in a collection - map96771.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map96771.get("keyB-96771"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01668.java b/OWASP DATASET CLEANED/BenchmarkTest01668.java deleted file mode 100644 index ecdbaa407c0c590e97dfd0e0f68455d8d981ab3e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01668.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01668") -public class BenchmarkTest01668 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01668" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01668" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01668" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map56839 = new java.util.HashMap(); - map56839.put("keyA-56839", "a_Value"); // put some stuff in the collection - map56839.put("keyB-56839", param); // put it in a collection - map56839.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map56839.get("keyB-56839"); // get it back out - bar = (String) map56839.get("keyA-56839"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01669.java b/OWASP DATASET CLEANED/BenchmarkTest01669.java deleted file mode 100644 index e471470253a60edf3c648cfbc852d1e057c17222..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01669.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01669") -public class BenchmarkTest01669 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01669" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01669" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01669" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01670.java b/OWASP DATASET CLEANED/BenchmarkTest01670.java deleted file mode 100644 index 1ba647f95a557c34879ad80a11c538921b40f0af..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01670.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01670") -public class BenchmarkTest01670 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01670" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01670" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01670" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01671.java b/OWASP DATASET CLEANED/BenchmarkTest01671.java deleted file mode 100644 index 1a8e32a16ad36062b718d9af744899e761087914..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01671.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01671") -public class BenchmarkTest01671 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01671" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01671" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01671" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01672.java b/OWASP DATASET CLEANED/BenchmarkTest01672.java deleted file mode 100644 index d4bdd945a17b1feccd5aba510b97aec04be999d4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01672.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01672") -public class BenchmarkTest01672 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01672" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01672" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01672" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01673.java b/OWASP DATASET CLEANED/BenchmarkTest01673.java deleted file mode 100644 index d51e0841af247718c39af0aeca54c7ce6aed9f73..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01673.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01673") -public class BenchmarkTest01673 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01673" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01673" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01673" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01674.java b/OWASP DATASET CLEANED/BenchmarkTest01674.java deleted file mode 100644 index d2212faeb2413996eeb8d5b04fca90c2c629c918..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01674.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01674") -public class BenchmarkTest01674 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01674" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01674" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01674" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01675.java b/OWASP DATASET CLEANED/BenchmarkTest01675.java deleted file mode 100644 index 25cd7035f7980d1387d806c5ec0d28972dbb8eee..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01675.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01675") -public class BenchmarkTest01675 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01675" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01675" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01675" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01676.java b/OWASP DATASET CLEANED/BenchmarkTest01676.java deleted file mode 100644 index 25480d57866805ba4cae926a0a2bf61685781a69..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01676.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01676") -public class BenchmarkTest01676 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01676" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01676" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01676" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01677.java b/OWASP DATASET CLEANED/BenchmarkTest01677.java deleted file mode 100644 index 55d068a3deb72b422620ee78069a7761268fbb3b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01677.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01677") -public class BenchmarkTest01677 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01677" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01677" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01677" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01678.java b/OWASP DATASET CLEANED/BenchmarkTest01678.java deleted file mode 100644 index 439ee88bb31712c4c42a0fa3e5069744918b7929..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01678.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01678") -public class BenchmarkTest01678 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01678" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01678" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01678" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a96171 = param; // assign - StringBuilder b96171 = new StringBuilder(a96171); // stick in stringbuilder - b96171.append(" SafeStuff"); // append some safe content - b96171.replace( - b96171.length() - "Chars".length(), - b96171.length(), - "Chars"); // replace some of the end content - java.util.HashMap map96171 = new java.util.HashMap(); - map96171.put("key96171", b96171.toString()); // put in a collection - String c96171 = (String) map96171.get("key96171"); // get it back out - String d96171 = c96171.substring(0, c96171.length() - 1); // extract most of it - String e96171 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d96171.getBytes()))); // B64 encode and decode it - String f96171 = e96171.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f96171); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01679.java b/OWASP DATASET CLEANED/BenchmarkTest01679.java deleted file mode 100644 index d25d7f33dbe065596548cd9470e46d620cc9d61d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01679.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01679") -public class BenchmarkTest01679 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01679" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01679" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01679" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01680.java b/OWASP DATASET CLEANED/BenchmarkTest01680.java deleted file mode 100644 index 3794521b32bd2abb9dbebc8f214eeda76900cd3c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01680.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01680") -public class BenchmarkTest01680 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01680" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01680" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01680" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01681.java b/OWASP DATASET CLEANED/BenchmarkTest01681.java deleted file mode 100644 index 54cdff7f66ad6132c8465355f80b88402d1902c7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01681.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01681") -public class BenchmarkTest01681 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01681" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01681" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01681" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map97890 = new java.util.HashMap(); - map97890.put("keyA-97890", "a_Value"); // put some stuff in the collection - map97890.put("keyB-97890", param); // put it in a collection - map97890.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map97890.get("keyB-97890"); // get it back out - bar = (String) map97890.get("keyA-97890"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01682.java b/OWASP DATASET CLEANED/BenchmarkTest01682.java deleted file mode 100644 index 27620e03e58bd45c26ee266fcace1fab04297080..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01682.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01682") -public class BenchmarkTest01682 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01682" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01682" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01682" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01683.java b/OWASP DATASET CLEANED/BenchmarkTest01683.java deleted file mode 100644 index 31ae7eaaef9ac32a14c82f173b01ae22138510f8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01683.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01683") -public class BenchmarkTest01683 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01683" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01683" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01683" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01684.java b/OWASP DATASET CLEANED/BenchmarkTest01684.java deleted file mode 100644 index 00fd07db25e7cd079444d5aed61a58226ee7400e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01684.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01684") -public class BenchmarkTest01684 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01684" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01684" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01684" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz77558 = new StringBuilder(param); - String bar = sbxyz77558.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01685.java b/OWASP DATASET CLEANED/BenchmarkTest01685.java deleted file mode 100644 index a466ea995c9578a302697129f871160d731b412b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01685.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01685") -public class BenchmarkTest01685 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01685" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01685" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01685" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01686.java b/OWASP DATASET CLEANED/BenchmarkTest01686.java deleted file mode 100644 index 9f62864d687a412b6406f4f88d88d76056569913..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01686.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01686") -public class BenchmarkTest01686 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01686" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01686" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01686" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01687.java b/OWASP DATASET CLEANED/BenchmarkTest01687.java deleted file mode 100644 index d862eb3c5207c3f0c0b285213a74aa87d6ff619a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01687.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01687") -public class BenchmarkTest01687 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01687" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01687" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01687" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01688.java b/OWASP DATASET CLEANED/BenchmarkTest01688.java deleted file mode 100644 index 16c23598f6e4564bde80052f8910f45106feb830..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01688.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01688") -public class BenchmarkTest01688 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01688" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01688" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01688" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01689.java b/OWASP DATASET CLEANED/BenchmarkTest01689.java deleted file mode 100644 index b155a17bc515da7e7c9e91955329cf8d25156ba0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01689.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01689") -public class BenchmarkTest01689 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01689" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01689" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01689" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01690.java b/OWASP DATASET CLEANED/BenchmarkTest01690.java deleted file mode 100644 index 05599ba795b6d5ec2fb95763d897d4d9edb21ec4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01690.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01690") -public class BenchmarkTest01690 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01690" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01690" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01690" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01691.java b/OWASP DATASET CLEANED/BenchmarkTest01691.java deleted file mode 100644 index 81696f0532902eb2b7e955968c96b9d0f1380589..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01691.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-01/BenchmarkTest01691") -public class BenchmarkTest01691 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01691" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01691" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01691" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01692.java b/OWASP DATASET CLEANED/BenchmarkTest01692.java deleted file mode 100644 index 64f7ba42f87664beb2d1f260c22eb8f0274479a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01692.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01692") -public class BenchmarkTest01692 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01692" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01692" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01692" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a28453 = param; // assign - StringBuilder b28453 = new StringBuilder(a28453); // stick in stringbuilder - b28453.append(" SafeStuff"); // append some safe content - b28453.replace( - b28453.length() - "Chars".length(), - b28453.length(), - "Chars"); // replace some of the end content - java.util.HashMap map28453 = new java.util.HashMap(); - map28453.put("key28453", b28453.toString()); // put in a collection - String c28453 = (String) map28453.get("key28453"); // get it back out - String d28453 = c28453.substring(0, c28453.length() - 1); // extract most of it - String e28453 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d28453.getBytes()))); // B64 encode and decode it - String f28453 = e28453.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g28453 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g28453); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01693.java b/OWASP DATASET CLEANED/BenchmarkTest01693.java deleted file mode 100644 index 6ae983ced7110cd05967ff819a22fe1103546c4b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01693.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01693") -public class BenchmarkTest01693 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01693" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01693" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01693" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01694.java b/OWASP DATASET CLEANED/BenchmarkTest01694.java deleted file mode 100644 index 196f3068e01fcdc9dc54d3b07d26568bee6f407c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01694.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01694") -public class BenchmarkTest01694 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01694" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01694" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01694" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01695.java b/OWASP DATASET CLEANED/BenchmarkTest01695.java deleted file mode 100644 index 361a011708dea99a1ff968897e10122669ae5846..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01695.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01695") -public class BenchmarkTest01695 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01695" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01695" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01695" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01696.java b/OWASP DATASET CLEANED/BenchmarkTest01696.java deleted file mode 100644 index 5d87ccc458826631950a4090f8b6b60573798d11..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01696.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01696") -public class BenchmarkTest01696 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01696" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01696" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01696" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map83181 = new java.util.HashMap(); - map83181.put("keyA-83181", "a-Value"); // put some stuff in the collection - map83181.put("keyB-83181", param); // put it in a collection - map83181.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map83181.get("keyB-83181"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01697.java b/OWASP DATASET CLEANED/BenchmarkTest01697.java deleted file mode 100644 index a2b2cde26c24baaf6a993eaa90e84cb714bbf9f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01697.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01697") -public class BenchmarkTest01697 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01697" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01697" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01697" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz19197 = new StringBuilder(param); - String bar = sbxyz19197.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01698.java b/OWASP DATASET CLEANED/BenchmarkTest01698.java deleted file mode 100644 index 7bccf765b7f127b6d4c5ad21efbfa6135ffcab07..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01698.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01698") -public class BenchmarkTest01698 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01698" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01698" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01698" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a72232 = param; // assign - StringBuilder b72232 = new StringBuilder(a72232); // stick in stringbuilder - b72232.append(" SafeStuff"); // append some safe content - b72232.replace( - b72232.length() - "Chars".length(), - b72232.length(), - "Chars"); // replace some of the end content - java.util.HashMap map72232 = new java.util.HashMap(); - map72232.put("key72232", b72232.toString()); // put in a collection - String c72232 = (String) map72232.get("key72232"); // get it back out - String d72232 = c72232.substring(0, c72232.length() - 1); // extract most of it - String e72232 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d72232.getBytes()))); // B64 encode and decode it - String f72232 = e72232.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g72232 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g72232); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01699.java b/OWASP DATASET CLEANED/BenchmarkTest01699.java deleted file mode 100644 index 394f7f741fa5cca1408a93faf21e018d028c4319..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01699.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01699") -public class BenchmarkTest01699 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01699" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01699" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01699" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01700.java b/OWASP DATASET CLEANED/BenchmarkTest01700.java deleted file mode 100644 index f411962af40160b551b81a1c49b6fd9cae91a9c2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01700.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01700") -public class BenchmarkTest01700 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01700" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01700" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01700" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01701.java b/OWASP DATASET CLEANED/BenchmarkTest01701.java deleted file mode 100644 index 6269dec90df3b85d06823b8c4b3d4919bedb485b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01701.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01701") -public class BenchmarkTest01701 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01701" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01701" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01701" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01702.java b/OWASP DATASET CLEANED/BenchmarkTest01702.java deleted file mode 100644 index 7873eb7e73bfe7afb5c6dc38a981e9bdd3cdab85..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01702.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01702") -public class BenchmarkTest01702 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01702" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01702" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01702" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01703.java b/OWASP DATASET CLEANED/BenchmarkTest01703.java deleted file mode 100644 index 41570cea38ab52c4b0abdfccf3d33258ef2cf9e0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01703.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01703") -public class BenchmarkTest01703 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01703" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01703" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01703" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01704.java b/OWASP DATASET CLEANED/BenchmarkTest01704.java deleted file mode 100644 index 415ef1504433d6d67be2d109efb7dcf72f7aee46..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01704.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01704") -public class BenchmarkTest01704 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01704" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01704" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01704" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01705.java b/OWASP DATASET CLEANED/BenchmarkTest01705.java deleted file mode 100644 index 1812f73b5eb2741b365ddd3b2d2c1e17de03bdb1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01705.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01705") -public class BenchmarkTest01705 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01705" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01705" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01705" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01706.java b/OWASP DATASET CLEANED/BenchmarkTest01706.java deleted file mode 100644 index 734511fe49a89e6a53ea06fe72b391f2d357f20f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01706.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01706") -public class BenchmarkTest01706 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01706" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01706" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01706" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01707.java b/OWASP DATASET CLEANED/BenchmarkTest01707.java deleted file mode 100644 index dd9ba8548a6eefeccf5df645f952ade9bc42d351..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01707.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01707") -public class BenchmarkTest01707 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01707" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01707" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01707" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map13101 = new java.util.HashMap(); - map13101.put("keyA-13101", "a-Value"); // put some stuff in the collection - map13101.put("keyB-13101", param); // put it in a collection - map13101.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map13101.get("keyB-13101"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01708.java b/OWASP DATASET CLEANED/BenchmarkTest01708.java deleted file mode 100644 index 626972abceb809e0f0f5ab36523bc3567b5034ac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01708.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01708") -public class BenchmarkTest01708 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01708" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01708" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01708" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01709.java b/OWASP DATASET CLEANED/BenchmarkTest01709.java deleted file mode 100644 index 2043c4372f4757fe3a1271476df37415d5155a9c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01709.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01709") -public class BenchmarkTest01709 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01709" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01709" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01709" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a15574 = param; // assign - StringBuilder b15574 = new StringBuilder(a15574); // stick in stringbuilder - b15574.append(" SafeStuff"); // append some safe content - b15574.replace( - b15574.length() - "Chars".length(), - b15574.length(), - "Chars"); // replace some of the end content - java.util.HashMap map15574 = new java.util.HashMap(); - map15574.put("key15574", b15574.toString()); // put in a collection - String c15574 = (String) map15574.get("key15574"); // get it back out - String d15574 = c15574.substring(0, c15574.length() - 1); // extract most of it - String e15574 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d15574.getBytes()))); // B64 encode and decode it - String f15574 = e15574.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f15574); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01710.java b/OWASP DATASET CLEANED/BenchmarkTest01710.java deleted file mode 100644 index a54111ea7d8b78e6cb34432b18bff7c2bb4026bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01710.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01710") -public class BenchmarkTest01710 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01710" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01710" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01710" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01711.java b/OWASP DATASET CLEANED/BenchmarkTest01711.java deleted file mode 100644 index a38168907a8dee3f7e72d9f8251b2ed7001831de..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01711.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01711") -public class BenchmarkTest01711 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01711" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01711" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01711" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01712.java b/OWASP DATASET CLEANED/BenchmarkTest01712.java deleted file mode 100644 index 07b5a4ed5e27d1537233ddd81da572ee7c21061f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01712.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01712") -public class BenchmarkTest01712 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01712" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01712" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01712" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map6261 = new java.util.HashMap(); - map6261.put("keyA-6261", "a-Value"); // put some stuff in the collection - map6261.put("keyB-6261", param); // put it in a collection - map6261.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map6261.get("keyB-6261"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01713.java b/OWASP DATASET CLEANED/BenchmarkTest01713.java deleted file mode 100644 index d0929cc2a800be8586e1099a8f2aa7beb66ae8fe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01713.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01713") -public class BenchmarkTest01713 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01713" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01713" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01713" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map83939 = new java.util.HashMap(); - map83939.put("keyA-83939", "a_Value"); // put some stuff in the collection - map83939.put("keyB-83939", param); // put it in a collection - map83939.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map83939.get("keyB-83939"); // get it back out - bar = (String) map83939.get("keyA-83939"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01714.java b/OWASP DATASET CLEANED/BenchmarkTest01714.java deleted file mode 100644 index 916429eabf92dedc501a322e629b0aa5a2cabb21..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01714.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01714") -public class BenchmarkTest01714 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01714" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01714" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01714" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01715.java b/OWASP DATASET CLEANED/BenchmarkTest01715.java deleted file mode 100644 index 853147f3a63a9182715b42da8fb8624476e967f2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01715.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01715") -public class BenchmarkTest01715 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01715" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01715" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01715" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01716.java b/OWASP DATASET CLEANED/BenchmarkTest01716.java deleted file mode 100644 index 41666d1b2894a0dc059c5a1fc2b5dc88f75e4905..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01716.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01716") -public class BenchmarkTest01716 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01716" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01716" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01716" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01717.java b/OWASP DATASET CLEANED/BenchmarkTest01717.java deleted file mode 100644 index 434aadd3475817beb26d3060fc7744e4a6bad555..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01717.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01717") -public class BenchmarkTest01717 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01717" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01717" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01717" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01718.java b/OWASP DATASET CLEANED/BenchmarkTest01718.java deleted file mode 100644 index d3e9e5ee3f70d4f330987d035504b915f9a92c91..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01718.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01718") -public class BenchmarkTest01718 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01718" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01718" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01718" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01719.java b/OWASP DATASET CLEANED/BenchmarkTest01719.java deleted file mode 100644 index 50596e9f63c82b01e7094d8dfda774b426b95bb7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01719.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01719") -public class BenchmarkTest01719 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01719" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01719" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01719" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01720.java b/OWASP DATASET CLEANED/BenchmarkTest01720.java deleted file mode 100644 index 66a65076132c21e4a964ad9b677aad385322d232..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01720.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01720") -public class BenchmarkTest01720 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01720" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01720" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01720" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01721.java b/OWASP DATASET CLEANED/BenchmarkTest01721.java deleted file mode 100644 index 80fa7ce887409c01d7ee61b84d1c2c59504ac08b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01721.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01721") -public class BenchmarkTest01721 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01721" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01721" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01721" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01722.java b/OWASP DATASET CLEANED/BenchmarkTest01722.java deleted file mode 100644 index a77e7fca4d220268e5c66c1c79bb5d689556f5c8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01722.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01722") -public class BenchmarkTest01722 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01722" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01722" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01722" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map33422 = new java.util.HashMap(); - map33422.put("keyA-33422", "a_Value"); // put some stuff in the collection - map33422.put("keyB-33422", param); // put it in a collection - map33422.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map33422.get("keyB-33422"); // get it back out - bar = (String) map33422.get("keyA-33422"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01723.java b/OWASP DATASET CLEANED/BenchmarkTest01723.java deleted file mode 100644 index 0de6e9b5badae4593ca1cbe1b6abc9f653556919..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01723.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01723") -public class BenchmarkTest01723 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01723" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01723" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01723" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01724.java b/OWASP DATASET CLEANED/BenchmarkTest01724.java deleted file mode 100644 index 15c84684360f989b75e95a49c08a5937a164b0a2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01724.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01724") -public class BenchmarkTest01724 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01724" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01724" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01724" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01725.java b/OWASP DATASET CLEANED/BenchmarkTest01725.java deleted file mode 100644 index 1d1cac9ccb030e6f7c794d076550a58ddcb7af8a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01725.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01725") -public class BenchmarkTest01725 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01725" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01725" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01725" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01726.java b/OWASP DATASET CLEANED/BenchmarkTest01726.java deleted file mode 100644 index e73791235cdaa4160b5015d3ceb5ad97d75dc77f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01726.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01726") -public class BenchmarkTest01726 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01726" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01726" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01726" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01727.java b/OWASP DATASET CLEANED/BenchmarkTest01727.java deleted file mode 100644 index 0f9fa34241fd2718c9d65c659f8c764cb7e0bb7f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01727.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01727") -public class BenchmarkTest01727 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01727" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01727" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01727" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01728.java b/OWASP DATASET CLEANED/BenchmarkTest01728.java deleted file mode 100644 index f22735fa6649ee2cbcf5d12fb82695768fe198c9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01728.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01728") -public class BenchmarkTest01728 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01728" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01728" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01728" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01729.java b/OWASP DATASET CLEANED/BenchmarkTest01729.java deleted file mode 100644 index d7828b29e615130de2c920338c9211d44a85107e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01729.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01729") -public class BenchmarkTest01729 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01729" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01729" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01729" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01730.java b/OWASP DATASET CLEANED/BenchmarkTest01730.java deleted file mode 100644 index f2b8d067576dac84bd178d34b9a3e7142c01e5b0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01730.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01730") -public class BenchmarkTest01730 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01730" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01730" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01730" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01731.java b/OWASP DATASET CLEANED/BenchmarkTest01731.java deleted file mode 100644 index dd30be2aeba237af3aa76bef76c90644b58d0e39..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01731.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01731") -public class BenchmarkTest01731 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01731" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01731" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01731" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01732.java b/OWASP DATASET CLEANED/BenchmarkTest01732.java deleted file mode 100644 index 8681e815ad983d4db2cfdd0b6aeb1f56ff83376f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01732.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01732") -public class BenchmarkTest01732 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01732" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01732" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01732" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01733.java b/OWASP DATASET CLEANED/BenchmarkTest01733.java deleted file mode 100644 index 4f5644ab3c529ab7167b5f5c391913b68366a8db..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01733.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01733") -public class BenchmarkTest01733 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01733" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01733" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01733" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01734.java b/OWASP DATASET CLEANED/BenchmarkTest01734.java deleted file mode 100644 index 76cde95480fa59f94873d339d05108e509344fd9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01734.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01734") -public class BenchmarkTest01734 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01734" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01734" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01734" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01735.java b/OWASP DATASET CLEANED/BenchmarkTest01735.java deleted file mode 100644 index 786e24e8ecadab804ee8d74b4461aac08f842210..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01735.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01735") -public class BenchmarkTest01735 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01735" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01735" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01735" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01736.java b/OWASP DATASET CLEANED/BenchmarkTest01736.java deleted file mode 100644 index 68b7b04c145177a2d728c7cc1d5a294780344f41..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01736.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01736") -public class BenchmarkTest01736 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest01736" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest01736" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest01736" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01737.java b/OWASP DATASET CLEANED/BenchmarkTest01737.java deleted file mode 100644 index 99a43cd32c0957f37384c2821002e31c3674243b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01737.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01737") -public class BenchmarkTest01737 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01737"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01738.java b/OWASP DATASET CLEANED/BenchmarkTest01738.java deleted file mode 100644 index 27e689460de92c48468fcd9a9279eab2b3b880bd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01738.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01738") -public class BenchmarkTest01738 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01738"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01739.java b/OWASP DATASET CLEANED/BenchmarkTest01739.java deleted file mode 100644 index fbbedc52a4cb8bc5decc4ed43e5a09f70ba965f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01739.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01739") -public class BenchmarkTest01739 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01739"); - - String bar = new Test().doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz60534 = new StringBuilder(param); - String bar = sbxyz60534.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01740.java b/OWASP DATASET CLEANED/BenchmarkTest01740.java deleted file mode 100644 index 5acc479bd6e36a2a5e667f31e2ccbf74d80a9e05..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01740.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01740") -public class BenchmarkTest01740 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01740"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01741.java b/OWASP DATASET CLEANED/BenchmarkTest01741.java deleted file mode 100644 index 2423b94d48ddd4205b003d9e37193a1ad3b3ffef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01741.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01741") -public class BenchmarkTest01741 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01741"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz82048 = new StringBuilder(param); - bar = - sbxyz82048 - .replace(param.length() - "Z".length(), param.length(), "Z") - .toString(); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01742.java b/OWASP DATASET CLEANED/BenchmarkTest01742.java deleted file mode 100644 index 173ab1b90aeb9162cfa151225ff98afb9d15fa0d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01742.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01742") -public class BenchmarkTest01742 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01742"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01743.java b/OWASP DATASET CLEANED/BenchmarkTest01743.java deleted file mode 100644 index 908ecc844aed299c939800a4d783132e6076fd3e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01743.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01743") -public class BenchmarkTest01743 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01743"); - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01744.java b/OWASP DATASET CLEANED/BenchmarkTest01744.java deleted file mode 100644 index 423ac23184d6c8715f75f45c55b4a8aed96a5615..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01744.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01744") -public class BenchmarkTest01744 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01744"); - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a17402 = param; // assign - StringBuilder b17402 = new StringBuilder(a17402); // stick in stringbuilder - b17402.append(" SafeStuff"); // append some safe content - b17402.replace( - b17402.length() - "Chars".length(), - b17402.length(), - "Chars"); // replace some of the end content - java.util.HashMap map17402 = new java.util.HashMap(); - map17402.put("key17402", b17402.toString()); // put in a collection - String c17402 = (String) map17402.get("key17402"); // get it back out - String d17402 = c17402.substring(0, c17402.length() - 1); // extract most of it - String e17402 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d17402.getBytes()))); // B64 encode and decode it - String f17402 = e17402.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g17402 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g17402); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01745.java b/OWASP DATASET CLEANED/BenchmarkTest01745.java deleted file mode 100644 index 2c835c36736b51c4317af179c2f927cf14d36304..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01745.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01745") -public class BenchmarkTest01745 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01745"); - - String bar = new Test().doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01746.java b/OWASP DATASET CLEANED/BenchmarkTest01746.java deleted file mode 100644 index 09176a01142636cd3532758e17a7ac308ee5df6f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01746.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01746") -public class BenchmarkTest01746 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01746"); - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01747.java b/OWASP DATASET CLEANED/BenchmarkTest01747.java deleted file mode 100644 index 56792f4baa5fed29ce1dfa40db82b8e4acebf8f8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01747.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01747") -public class BenchmarkTest01747 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01747"); - - String bar = new Test().doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01748.java b/OWASP DATASET CLEANED/BenchmarkTest01748.java deleted file mode 100644 index 05d03b8466d578d96f306106fde046501dfd0ace..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01748.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01748") -public class BenchmarkTest01748 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01748"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01749.java b/OWASP DATASET CLEANED/BenchmarkTest01749.java deleted file mode 100644 index 0a1664e0a370aa842a7a727d169b2ce32b2d2d11..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01749.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01749") -public class BenchmarkTest01749 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01749"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01750.java b/OWASP DATASET CLEANED/BenchmarkTest01750.java deleted file mode 100644 index 2cd4b888fb4e1b546e3f816165b6d93f94a2a196..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01750.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01750") -public class BenchmarkTest01750 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01750"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01751.java b/OWASP DATASET CLEANED/BenchmarkTest01751.java deleted file mode 100644 index 3b780b2dd5debd56071838f89de4d31eacf96d73..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01751.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01751") -public class BenchmarkTest01751 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01751"); - - String bar = new Test().doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01752.java b/OWASP DATASET CLEANED/BenchmarkTest01752.java deleted file mode 100644 index 524866aa463370ee524de40a573458f522e01e19..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01752.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01752") -public class BenchmarkTest01752 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01752"); - - String bar = new Test().doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map11351 = new java.util.HashMap(); - map11351.put("keyA-11351", "a-Value"); // put some stuff in the collection - map11351.put("keyB-11351", param); // put it in a collection - map11351.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map11351.get("keyB-11351"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01753.java b/OWASP DATASET CLEANED/BenchmarkTest01753.java deleted file mode 100644 index 0cc45bff7f88f3006a43572b4d8d6a90e77b458f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01753.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01753") -public class BenchmarkTest01753 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01753"); - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01754.java b/OWASP DATASET CLEANED/BenchmarkTest01754.java deleted file mode 100644 index a9b09462553dfbd1a4d33fb5afb3682d55866627..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01754.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01754") -public class BenchmarkTest01754 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01754"); - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map91865 = new java.util.HashMap(); - map91865.put("keyA-91865", "a-Value"); // put some stuff in the collection - map91865.put("keyB-91865", param); // put it in a collection - map91865.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map91865.get("keyB-91865"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01755.java b/OWASP DATASET CLEANED/BenchmarkTest01755.java deleted file mode 100644 index 7dbbae0442f3ce80d707aec6c039141ed7b22208..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01755.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01755") -public class BenchmarkTest01755 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01755"); - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map69635 = new java.util.HashMap(); - map69635.put("keyA-69635", "a-Value"); // put some stuff in the collection - map69635.put("keyB-69635", param); // put it in a collection - map69635.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map69635.get("keyB-69635"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01756.java b/OWASP DATASET CLEANED/BenchmarkTest01756.java deleted file mode 100644 index f8ea3256971ade50f61e32b9c4e56a55c23018e3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01756.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01756") -public class BenchmarkTest01756 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01756"); - - String bar = new Test().doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01757.java b/OWASP DATASET CLEANED/BenchmarkTest01757.java deleted file mode 100644 index 189c58bbd675eb7af9ff94b99e30bb98e5ba0420..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01757.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01757") -public class BenchmarkTest01757 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01757"); - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01758.java b/OWASP DATASET CLEANED/BenchmarkTest01758.java deleted file mode 100644 index 812696b21bbfd44a867b499648ce40ea19afd5aa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01758.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01758") -public class BenchmarkTest01758 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01758"); - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01759.java b/OWASP DATASET CLEANED/BenchmarkTest01759.java deleted file mode 100644 index 8b9430117d13b5c91dbb7f95b175255dae4dc948..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01759.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-01/BenchmarkTest01759") -public class BenchmarkTest01759 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01759"); - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01760.java b/OWASP DATASET CLEANED/BenchmarkTest01760.java deleted file mode 100644 index 15d84e639aadeaf5c8573f7027242d23f504f4d3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01760.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01760") -public class BenchmarkTest01760 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01760"); - - String bar = new Test().doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01761.java b/OWASP DATASET CLEANED/BenchmarkTest01761.java deleted file mode 100644 index ed6f6b10851751ac454ac712755f854be6375ebd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01761.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01761") -public class BenchmarkTest01761 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01761"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01762.java b/OWASP DATASET CLEANED/BenchmarkTest01762.java deleted file mode 100644 index 087fda15fc713cc5c8122df7dcb9f3cc68ebfa2c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01762.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01762") -public class BenchmarkTest01762 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01762"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01763.java b/OWASP DATASET CLEANED/BenchmarkTest01763.java deleted file mode 100644 index 31bbf69c76102392edc6d2181f7613f28a1b966b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01763.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01763") -public class BenchmarkTest01763 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01763"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01764.java b/OWASP DATASET CLEANED/BenchmarkTest01764.java deleted file mode 100644 index fc842382cb5f1d5c59a227a38fb267d199ef3f8a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01764.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01764") -public class BenchmarkTest01764 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01764"); - - String bar = new Test().doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01765.java b/OWASP DATASET CLEANED/BenchmarkTest01765.java deleted file mode 100644 index fbf30d1f2af67cc9a4d3401bae9c4193fbcd01ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01765.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01765") -public class BenchmarkTest01765 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01765"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01766.java b/OWASP DATASET CLEANED/BenchmarkTest01766.java deleted file mode 100644 index c113d21a23b51fd09aeb9ba32d275f3aeb9698d0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01766.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01766") -public class BenchmarkTest01766 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01766"); - - String bar = new Test().doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01767.java b/OWASP DATASET CLEANED/BenchmarkTest01767.java deleted file mode 100644 index 5656d504dc84350f979ddc42b74c95d0eda4fdcc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01767.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01767") -public class BenchmarkTest01767 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01767"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01768.java b/OWASP DATASET CLEANED/BenchmarkTest01768.java deleted file mode 100644 index b019e5389bc8d5e528cb7058ab06140bb239dc28..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01768.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01768") -public class BenchmarkTest01768 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01768"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01769.java b/OWASP DATASET CLEANED/BenchmarkTest01769.java deleted file mode 100644 index 9006bbce526ddd3ae5534843266c6f956b154798..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01769.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01769") -public class BenchmarkTest01769 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01769"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01770.java b/OWASP DATASET CLEANED/BenchmarkTest01770.java deleted file mode 100644 index dd694a0b6fbadebdfafd810e23f30841c6d5a8bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01770.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01770") -public class BenchmarkTest01770 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01770"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz41282 = new StringBuilder(param); - String bar = sbxyz41282.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01771.java b/OWASP DATASET CLEANED/BenchmarkTest01771.java deleted file mode 100644 index 1078d4bda44770548059d8b7a8055cd1810f8000..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01771.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01771") -public class BenchmarkTest01771 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01771"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a58724 = param; // assign - StringBuilder b58724 = new StringBuilder(a58724); // stick in stringbuilder - b58724.append(" SafeStuff"); // append some safe content - b58724.replace( - b58724.length() - "Chars".length(), - b58724.length(), - "Chars"); // replace some of the end content - java.util.HashMap map58724 = new java.util.HashMap(); - map58724.put("key58724", b58724.toString()); // put in a collection - String c58724 = (String) map58724.get("key58724"); // get it back out - String d58724 = c58724.substring(0, c58724.length() - 1); // extract most of it - String e58724 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d58724.getBytes()))); // B64 encode and decode it - String f58724 = e58724.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f58724); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01772.java b/OWASP DATASET CLEANED/BenchmarkTest01772.java deleted file mode 100644 index db1a1eadebe5843155a8206a82fc8d9716b9ef7d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01772.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01772") -public class BenchmarkTest01772 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01772"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz76680 = new StringBuilder(param); - String bar = sbxyz76680.append("_SafeStuff").toString(); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01773.java b/OWASP DATASET CLEANED/BenchmarkTest01773.java deleted file mode 100644 index 5c5dd96033460aee8d8112b7799085731855cdfd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01773.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01773") -public class BenchmarkTest01773 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01773"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01774.java b/OWASP DATASET CLEANED/BenchmarkTest01774.java deleted file mode 100644 index 8cac42f65d0d24d8a88f4e0a0fb8eba74c780c08..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01774.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01774") -public class BenchmarkTest01774 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01774"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map58318 = new java.util.HashMap(); - map58318.put("keyA-58318", "a_Value"); // put some stuff in the collection - map58318.put("keyB-58318", param); // put it in a collection - map58318.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map58318.get("keyB-58318"); // get it back out - bar = (String) map58318.get("keyA-58318"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01775.java b/OWASP DATASET CLEANED/BenchmarkTest01775.java deleted file mode 100644 index 81122baebe11fb59c558621d6c2ba7e51c2c8f13..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01775.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01775") -public class BenchmarkTest01775 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01775"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01776.java b/OWASP DATASET CLEANED/BenchmarkTest01776.java deleted file mode 100644 index f8d7c2e7e378a3c7f49b02b21b8857a11ce9c7b3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01776.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01776") -public class BenchmarkTest01776 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01776"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map3531 = new java.util.HashMap(); - map3531.put("keyA-3531", "a_Value"); // put some stuff in the collection - map3531.put("keyB-3531", param); // put it in a collection - map3531.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map3531.get("keyB-3531"); // get it back out - bar = (String) map3531.get("keyA-3531"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01777.java b/OWASP DATASET CLEANED/BenchmarkTest01777.java deleted file mode 100644 index b90dec65237743d1658f575a38b9708f983a478e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01777.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01777") -public class BenchmarkTest01777 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01777"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01778.java b/OWASP DATASET CLEANED/BenchmarkTest01778.java deleted file mode 100644 index 07631e4d6d62a72f2e438fa2ebcce04356b016f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01778.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01778") -public class BenchmarkTest01778 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01778"); - - String bar = new Test().doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01779.java b/OWASP DATASET CLEANED/BenchmarkTest01779.java deleted file mode 100644 index fbd29c6eccb25193169a0f7e5982a5fc8c31dcf8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01779.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01779") -public class BenchmarkTest01779 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01779"); - - String bar = new Test().doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01780.java b/OWASP DATASET CLEANED/BenchmarkTest01780.java deleted file mode 100644 index 66a6362c18fc3757dc492ca73744a0565e3ae410..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01780.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01780") -public class BenchmarkTest01780 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01780"); - - String bar = new Test().doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map90655 = new java.util.HashMap(); - map90655.put("keyA-90655", "a_Value"); // put some stuff in the collection - map90655.put("keyB-90655", param); // put it in a collection - map90655.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map90655.get("keyB-90655"); // get it back out - bar = (String) map90655.get("keyA-90655"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01781.java b/OWASP DATASET CLEANED/BenchmarkTest01781.java deleted file mode 100644 index 7f86beb62822a1ba0779b8beaac1d2d5cbb357d3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01781.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01781") -public class BenchmarkTest01781 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01781"); - - String bar = new Test().doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01782.java b/OWASP DATASET CLEANED/BenchmarkTest01782.java deleted file mode 100644 index b0b2bf4519bf98934df7fee3066f204990792789..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01782.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01782") -public class BenchmarkTest01782 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01782"); - - String bar = new Test().doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01783.java b/OWASP DATASET CLEANED/BenchmarkTest01783.java deleted file mode 100644 index f62e0471c9bc53007304d3ad5200554bf7ed2219..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01783.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01783") -public class BenchmarkTest01783 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01783"); - - String bar = new Test().doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01784.java b/OWASP DATASET CLEANED/BenchmarkTest01784.java deleted file mode 100644 index b111ad6e145241e52bd322312dfccde5d3811a3a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01784.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01784") -public class BenchmarkTest01784 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01784"); - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01785.java b/OWASP DATASET CLEANED/BenchmarkTest01785.java deleted file mode 100644 index d3d012faf8ae2df9105e080706e604757d992451..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01785.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01785") -public class BenchmarkTest01785 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01785"); - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01786.java b/OWASP DATASET CLEANED/BenchmarkTest01786.java deleted file mode 100644 index 3166859a5fbc70e864cb8f14afb60e77240bce7a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01786.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01786") -public class BenchmarkTest01786 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01786"); - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01787.java b/OWASP DATASET CLEANED/BenchmarkTest01787.java deleted file mode 100644 index 03bdfc988f97d2b8413d8a45109f91fecd12b252..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01787.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-03/BenchmarkTest01787") -public class BenchmarkTest01787 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01787"); - - String bar = new Test().doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01788.java b/OWASP DATASET CLEANED/BenchmarkTest01788.java deleted file mode 100644 index 47410321f8ae5bf69973886679a515600852c724..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01788.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01788") -public class BenchmarkTest01788 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01788"); - - String bar = new Test().doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01789.java b/OWASP DATASET CLEANED/BenchmarkTest01789.java deleted file mode 100644 index 755bfc25b133999e9fa09acd4b12da713ffa81af..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01789.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01789") -public class BenchmarkTest01789 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01789"); - - String bar = new Test().doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01790.java b/OWASP DATASET CLEANED/BenchmarkTest01790.java deleted file mode 100644 index 24770caae87570d731f0d316ccdd21a7be6c31fa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01790.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01790") -public class BenchmarkTest01790 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01790"); - - String bar = new Test().doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01791.java b/OWASP DATASET CLEANED/BenchmarkTest01791.java deleted file mode 100644 index d1e1c6dac5ab29849ae5c00eb67bf4c646fa385d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01791.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01791") -public class BenchmarkTest01791 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01791"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01792.java b/OWASP DATASET CLEANED/BenchmarkTest01792.java deleted file mode 100644 index 2951336ed4ca0c3d5a77ebb9afeff4554c1fded0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01792.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01792") -public class BenchmarkTest01792 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01792"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01793.java b/OWASP DATASET CLEANED/BenchmarkTest01793.java deleted file mode 100644 index 6ca03a3d8ec3aef71d88dd739554ea40ed9b9ca6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01793.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01793") -public class BenchmarkTest01793 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01793"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01794.java b/OWASP DATASET CLEANED/BenchmarkTest01794.java deleted file mode 100644 index f8b8874ea0d413eece4d327ca72a9c7696574629..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01794.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01794") -public class BenchmarkTest01794 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01794"); - - String bar = new Test().doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01795.java b/OWASP DATASET CLEANED/BenchmarkTest01795.java deleted file mode 100644 index 260283df3a7718d9f16d7d3f8b52ea283f236918..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01795.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01795") -public class BenchmarkTest01795 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01795"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01796.java b/OWASP DATASET CLEANED/BenchmarkTest01796.java deleted file mode 100644 index a89ff96910e9d617e2570bb292495105030c7f51..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01796.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01796") -public class BenchmarkTest01796 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01796"); - - String bar = new Test().doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01797.java b/OWASP DATASET CLEANED/BenchmarkTest01797.java deleted file mode 100644 index f5e51901b5a50156983a75b7ecb957aa4995849b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01797.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01797") -public class BenchmarkTest01797 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01797"); - - String bar = new Test().doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map85341 = new java.util.HashMap(); - map85341.put("keyA-85341", "a_Value"); // put some stuff in the collection - map85341.put("keyB-85341", param); // put it in a collection - map85341.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map85341.get("keyB-85341"); // get it back out - bar = (String) map85341.get("keyA-85341"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01798.java b/OWASP DATASET CLEANED/BenchmarkTest01798.java deleted file mode 100644 index 6c3a3f964eeee72ccd6077e613216ed369fdc337..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01798.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01798") -public class BenchmarkTest01798 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01798"); - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01799.java b/OWASP DATASET CLEANED/BenchmarkTest01799.java deleted file mode 100644 index ce57305699aa0732de70b36389e8d9bbf0e5fa16..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01799.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01799") -public class BenchmarkTest01799 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01799"); - - String bar = new Test().doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01800.java b/OWASP DATASET CLEANED/BenchmarkTest01800.java deleted file mode 100644 index ecf3d16501a696ca8a6d0b80ac8d6cfd459f7499..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01800.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01800") -public class BenchmarkTest01800 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01800"); - - String bar = new Test().doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a71684 = param; // assign - StringBuilder b71684 = new StringBuilder(a71684); // stick in stringbuilder - b71684.append(" SafeStuff"); // append some safe content - b71684.replace( - b71684.length() - "Chars".length(), - b71684.length(), - "Chars"); // replace some of the end content - java.util.HashMap map71684 = new java.util.HashMap(); - map71684.put("key71684", b71684.toString()); // put in a collection - String c71684 = (String) map71684.get("key71684"); // get it back out - String d71684 = c71684.substring(0, c71684.length() - 1); // extract most of it - String e71684 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d71684.getBytes()))); // B64 encode and decode it - String f71684 = e71684.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f71684); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01801.java b/OWASP DATASET CLEANED/BenchmarkTest01801.java deleted file mode 100644 index 3ba42841919f34b097d8f6be8860a4bdd38695c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01801.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01801") -public class BenchmarkTest01801 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01801"); - - String bar = new Test().doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01802.java b/OWASP DATASET CLEANED/BenchmarkTest01802.java deleted file mode 100644 index 619076d3e2a4833e708c75345af81e058e7bddd3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01802.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01802") -public class BenchmarkTest01802 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01802"); - - String bar = new Test().doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01803.java b/OWASP DATASET CLEANED/BenchmarkTest01803.java deleted file mode 100644 index b610d3dcf080c4bf26af0a4e23b5ef4fda22db1e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01803.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01803") -public class BenchmarkTest01803 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01803"); - - String bar = new Test().doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01804.java b/OWASP DATASET CLEANED/BenchmarkTest01804.java deleted file mode 100644 index fb6da6d9c538f943b87508750bd5216828510110..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01804.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01804") -public class BenchmarkTest01804 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01804"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map31481 = new java.util.HashMap(); - map31481.put("keyA-31481", "a_Value"); // put some stuff in the collection - map31481.put("keyB-31481", param); // put it in a collection - map31481.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map31481.get("keyB-31481"); // get it back out - bar = (String) map31481.get("keyA-31481"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01805.java b/OWASP DATASET CLEANED/BenchmarkTest01805.java deleted file mode 100644 index bb7d83eae7f342de9bed50b8cedf42b9d3a80baf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01805.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01805") -public class BenchmarkTest01805 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01805"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map10271 = new java.util.HashMap(); - map10271.put("keyA-10271", "a_Value"); // put some stuff in the collection - map10271.put("keyB-10271", param); // put it in a collection - map10271.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map10271.get("keyB-10271"); // get it back out - bar = (String) map10271.get("keyA-10271"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01806.java b/OWASP DATASET CLEANED/BenchmarkTest01806.java deleted file mode 100644 index 5afa5f23b4122b39561e6faab46172044a943aea..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01806.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01806") -public class BenchmarkTest01806 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01806"); - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01807.java b/OWASP DATASET CLEANED/BenchmarkTest01807.java deleted file mode 100644 index 307a8ee06c71bc0fa6cee104298380988bbc21cd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01807.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01807") -public class BenchmarkTest01807 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01807"); - - String bar = new Test().doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01808.java b/OWASP DATASET CLEANED/BenchmarkTest01808.java deleted file mode 100644 index 278e6b2679c595900fef66274dc5d501e459a751..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01808.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01808") -public class BenchmarkTest01808 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01808"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01809.java b/OWASP DATASET CLEANED/BenchmarkTest01809.java deleted file mode 100644 index 0d21da2b1d80fdf49cea1bdfcab22a41f7c23538..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01809.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01809") -public class BenchmarkTest01809 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01809"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a64594 = param; // assign - StringBuilder b64594 = new StringBuilder(a64594); // stick in stringbuilder - b64594.append(" SafeStuff"); // append some safe content - b64594.replace( - b64594.length() - "Chars".length(), - b64594.length(), - "Chars"); // replace some of the end content - java.util.HashMap map64594 = new java.util.HashMap(); - map64594.put("key64594", b64594.toString()); // put in a collection - String c64594 = (String) map64594.get("key64594"); // get it back out - String d64594 = c64594.substring(0, c64594.length() - 1); // extract most of it - String e64594 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d64594.getBytes()))); // B64 encode and decode it - String f64594 = e64594.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g64594 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g64594); // reflection - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01810.java b/OWASP DATASET CLEANED/BenchmarkTest01810.java deleted file mode 100644 index 1a083344fce096a1709b97357fdb182bcf8b32d5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01810.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01810") -public class BenchmarkTest01810 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01810"); - - String bar = new Test().doSomething(request, param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01811.java b/OWASP DATASET CLEANED/BenchmarkTest01811.java deleted file mode 100644 index 6a01a19c0641ece01d3072705b277b361cfdeafa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01811.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01811") -public class BenchmarkTest01811 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01811"); - - String bar = new Test().doSomething(request, param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map31047 = new java.util.HashMap(); - map31047.put("keyA-31047", "a_Value"); // put some stuff in the collection - map31047.put("keyB-31047", param); // put it in a collection - map31047.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map31047.get("keyB-31047"); // get it back out - bar = (String) map31047.get("keyA-31047"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01812.java b/OWASP DATASET CLEANED/BenchmarkTest01812.java deleted file mode 100644 index 2e880806d016fc330a96623e4fa7e08464f58cbe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01812.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01812") -public class BenchmarkTest01812 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01812"); - - String bar = new Test().doSomething(request, param); - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map20703 = new java.util.HashMap(); - map20703.put("keyA-20703", "a_Value"); // put some stuff in the collection - map20703.put("keyB-20703", param); // put it in a collection - map20703.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map20703.get("keyB-20703"); // get it back out - bar = (String) map20703.get("keyA-20703"); // get safe value back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01813.java b/OWASP DATASET CLEANED/BenchmarkTest01813.java deleted file mode 100644 index aed1088376089228ff4b4c3895bf5fe87d45962a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01813.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-03/BenchmarkTest01813") -public class BenchmarkTest01813 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01813"); - - String bar = new Test().doSomething(request, param); - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01814.java b/OWASP DATASET CLEANED/BenchmarkTest01814.java deleted file mode 100644 index 1908204d72dfdbb1600541285771dd2f45bc7a73..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01814.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01814") -public class BenchmarkTest01814 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01814"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01815.java b/OWASP DATASET CLEANED/BenchmarkTest01815.java deleted file mode 100644 index 527192ca85e519db7398e8c84aa3af40bb89b250..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01815.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01815") -public class BenchmarkTest01815 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01815"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map72704 = new java.util.HashMap(); - map72704.put("keyA-72704", "a-Value"); // put some stuff in the collection - map72704.put("keyB-72704", param); // put it in a collection - map72704.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map72704.get("keyB-72704"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01816.java b/OWASP DATASET CLEANED/BenchmarkTest01816.java deleted file mode 100644 index 37f6cd4c41c1a8dbe6296e756e58f022eaaa37c2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01816.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01816") -public class BenchmarkTest01816 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01816"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01817.java b/OWASP DATASET CLEANED/BenchmarkTest01817.java deleted file mode 100644 index 54e1bb776a4dc5060d4aef08f9d002ab61520284..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01817.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01817") -public class BenchmarkTest01817 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01817"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01818.java b/OWASP DATASET CLEANED/BenchmarkTest01818.java deleted file mode 100644 index b3ef628ad6574bee90da47c2cb6e55cb4f8a8e4a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01818.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01818") -public class BenchmarkTest01818 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01818"); - - String bar = new Test().doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01819.java b/OWASP DATASET CLEANED/BenchmarkTest01819.java deleted file mode 100644 index 4b9ee78d8f12b5ccff84f29475cf90446eefea1e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01819.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01819") -public class BenchmarkTest01819 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01819"); - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map64759 = new java.util.HashMap(); - map64759.put("keyA-64759", "a-Value"); // put some stuff in the collection - map64759.put("keyB-64759", param); // put it in a collection - map64759.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map64759.get("keyB-64759"); // get it back out - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01820.java b/OWASP DATASET CLEANED/BenchmarkTest01820.java deleted file mode 100644 index 905b70a0ca7d0f01dda3d3a168e7bb515c356bbf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01820.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01820") -public class BenchmarkTest01820 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01820"); - - String bar = new Test().doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01821.java b/OWASP DATASET CLEANED/BenchmarkTest01821.java deleted file mode 100644 index c74d6262e6a2e3b1fc20cc3ab6728100dd05c242..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01821.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Dave Wichers - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01821") -public class BenchmarkTest01821 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest01821"); - - String bar = new Test().doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private class Test { - - public String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } - } // end innerclass Test -} // end DataflowThruInnerClass diff --git a/OWASP DATASET CLEANED/BenchmarkTest01822.java b/OWASP DATASET CLEANED/BenchmarkTest01822.java deleted file mode 100644 index 652063479fe991cffe6092106393f4fbffaddbe0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01822.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01822") -public class BenchmarkTest01822 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01822", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-02/BenchmarkTest01822.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01822")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map20550 = new java.util.HashMap(); - map20550.put("keyA-20550", "a-Value"); // put some stuff in the collection - map20550.put("keyB-20550", param); // put it in a collection - map20550.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map20550.get("keyB-20550"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01823.java b/OWASP DATASET CLEANED/BenchmarkTest01823.java deleted file mode 100644 index 14b27319655be4324781fd939ed2a9b89046c4c0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01823.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01823") -public class BenchmarkTest01823 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01823", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-02/BenchmarkTest01823.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01823")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01824.java b/OWASP DATASET CLEANED/BenchmarkTest01824.java deleted file mode 100644 index faa6c3b76b4f26504a2034aee4e068f59e18133a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01824.java +++ /dev/null @@ -1,176 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01824") -public class BenchmarkTest01824 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01824", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-02/BenchmarkTest01824.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01824")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01825.java b/OWASP DATASET CLEANED/BenchmarkTest01825.java deleted file mode 100644 index 3c9e3444780856546e399867164299c8de5b9834..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01825.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01825") -public class BenchmarkTest01825 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01825", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-02/BenchmarkTest01825.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01825")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01826.java b/OWASP DATASET CLEANED/BenchmarkTest01826.java deleted file mode 100644 index ed98148017a8dde521c4d88cb6d7a54af9ddb4f6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01826.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01826") -public class BenchmarkTest01826 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01826", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-02/BenchmarkTest01826.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01826")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map38565 = new java.util.HashMap(); - map38565.put("keyA-38565", "a_Value"); // put some stuff in the collection - map38565.put("keyB-38565", param); // put it in a collection - map38565.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map38565.get("keyB-38565"); // get it back out - bar = (String) map38565.get("keyA-38565"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01827.java b/OWASP DATASET CLEANED/BenchmarkTest01827.java deleted file mode 100644 index 1a0206901d1b5bfa4b4303567c6ca2ed2788cb32..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01827.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01827") -public class BenchmarkTest01827 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01827", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-02/BenchmarkTest01827.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01827")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01828.java b/OWASP DATASET CLEANED/BenchmarkTest01828.java deleted file mode 100644 index c3f800b1fff25e9e06a737f0abc5e25661ffece0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01828.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01828") -public class BenchmarkTest01828 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01828", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-02/BenchmarkTest01828.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01828")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz6675 = new StringBuilder(param); - String bar = sbxyz6675.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01829.java b/OWASP DATASET CLEANED/BenchmarkTest01829.java deleted file mode 100644 index dc5d3143b11eaf0f028ad4a4422155f1ff7b12c2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01829.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01829") -public class BenchmarkTest01829 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01829", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-02/BenchmarkTest01829.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01829")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a60792 = param; // assign - StringBuilder b60792 = new StringBuilder(a60792); // stick in stringbuilder - b60792.append(" SafeStuff"); // append some safe content - b60792.replace( - b60792.length() - "Chars".length(), - b60792.length(), - "Chars"); // replace some of the end content - java.util.HashMap map60792 = new java.util.HashMap(); - map60792.put("key60792", b60792.toString()); // put in a collection - String c60792 = (String) map60792.get("key60792"); // get it back out - String d60792 = c60792.substring(0, c60792.length() - 1); // extract most of it - String e60792 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d60792.getBytes()))); // B64 encode and decode it - String f60792 = e60792.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f60792); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01830.java b/OWASP DATASET CLEANED/BenchmarkTest01830.java deleted file mode 100644 index a1f3a82f1037959d665d4cb0fda9c80c28364461..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01830.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01830") -public class BenchmarkTest01830 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01830", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/crypto-02/BenchmarkTest01830.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01830")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01831.java b/OWASP DATASET CLEANED/BenchmarkTest01831.java deleted file mode 100644 index e1522266d396f959015507cefe0fba750c50cdae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01831.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01831") -public class BenchmarkTest01831 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01831", "Ms+Bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/ldapi-00/BenchmarkTest01831.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01831")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01832.java b/OWASP DATASET CLEANED/BenchmarkTest01832.java deleted file mode 100644 index 9fc57602d03314a288a21cd9b3b9e0d41d10d7f1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01832.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01832") -public class BenchmarkTest01832 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01832", "Ms+Bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/ldapi-00/BenchmarkTest01832.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01832")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01833.java b/OWASP DATASET CLEANED/BenchmarkTest01833.java deleted file mode 100644 index 5c586b78c68df8591039da0a15de836786eac8c0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01833.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01833") -public class BenchmarkTest01833 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01833", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-02/BenchmarkTest01833.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01833")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map9325 = new java.util.HashMap(); - map9325.put("keyA-9325", "a-Value"); // put some stuff in the collection - map9325.put("keyB-9325", param); // put it in a collection - map9325.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map9325.get("keyB-9325"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01834.java b/OWASP DATASET CLEANED/BenchmarkTest01834.java deleted file mode 100644 index 8a6f1e4ef9ac846fd121b54eeef6f2ffb5f15370..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01834.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01834") -public class BenchmarkTest01834 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01834", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-02/BenchmarkTest01834.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01834")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01835.java b/OWASP DATASET CLEANED/BenchmarkTest01835.java deleted file mode 100644 index ee2b8a4c46af123914c689eb3a401b5c250e0101..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01835.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01835") -public class BenchmarkTest01835 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01835", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-02/BenchmarkTest01835.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01835")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01836.java b/OWASP DATASET CLEANED/BenchmarkTest01836.java deleted file mode 100644 index 6bd242fef47a511fede65a126fe0b72105fca2ce..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01836.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01836") -public class BenchmarkTest01836 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01836", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-02/BenchmarkTest01836.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01836")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map78713 = new java.util.HashMap(); - map78713.put("keyA-78713", "a-Value"); // put some stuff in the collection - map78713.put("keyB-78713", param); // put it in a collection - map78713.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map78713.get("keyB-78713"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01837.java b/OWASP DATASET CLEANED/BenchmarkTest01837.java deleted file mode 100644 index f9f77e51e9847838776de8ad71a66f1e2bcab185..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01837.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01837") -public class BenchmarkTest01837 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01837", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-02/BenchmarkTest01837.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01837")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01838.java b/OWASP DATASET CLEANED/BenchmarkTest01838.java deleted file mode 100644 index 02f4cb14c9899777111f1a3b19b0eb6dac5e7d67..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01838.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01838") -public class BenchmarkTest01838 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01838", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-02/BenchmarkTest01838.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01838")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01839.java b/OWASP DATASET CLEANED/BenchmarkTest01839.java deleted file mode 100644 index 5cd170d670a3fe26fa6176a14a3524a177be7ebf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01839.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01839") -public class BenchmarkTest01839 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01839", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-02/BenchmarkTest01839.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01839")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01840.java b/OWASP DATASET CLEANED/BenchmarkTest01840.java deleted file mode 100644 index 04533a0c2bd8d72e946d00ebd8aa0057bafd032f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01840.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01840") -public class BenchmarkTest01840 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01840", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-02/BenchmarkTest01840.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01840")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01841.java b/OWASP DATASET CLEANED/BenchmarkTest01841.java deleted file mode 100644 index a7f71ab13640ff37123019f0c9d5745418b5b965..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01841.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01841") -public class BenchmarkTest01841 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01841", "FileName"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/pathtraver-02/BenchmarkTest01841.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01841")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a14546 = param; // assign - StringBuilder b14546 = new StringBuilder(a14546); // stick in stringbuilder - b14546.append(" SafeStuff"); // append some safe content - b14546.replace( - b14546.length() - "Chars".length(), - b14546.length(), - "Chars"); // replace some of the end content - java.util.HashMap map14546 = new java.util.HashMap(); - map14546.put("key14546", b14546.toString()); // put in a collection - String c14546 = (String) map14546.get("key14546"); // get it back out - String d14546 = c14546.substring(0, c14546.length() - 1); // extract most of it - String e14546 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d14546.getBytes()))); // B64 encode and decode it - String f14546 = e14546.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g14546 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g14546); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01842.java b/OWASP DATASET CLEANED/BenchmarkTest01842.java deleted file mode 100644 index d1502aaa419365cc111322f21d3b3e23d6187b16..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01842.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01842") -public class BenchmarkTest01842 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01842", "anything"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01842.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01842")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01843.java b/OWASP DATASET CLEANED/BenchmarkTest01843.java deleted file mode 100644 index 63f28da3863f65f61b1e5c77ab5d40af640198a6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01843.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01843") -public class BenchmarkTest01843 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01843", "anything"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01843.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01843")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01844.java b/OWASP DATASET CLEANED/BenchmarkTest01844.java deleted file mode 100644 index 8b819ee867f26a8f34c3c7629ebcdcb61310a851..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01844.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01844") -public class BenchmarkTest01844 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01844", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-02/BenchmarkTest01844.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01844")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a37183 = param; // assign - StringBuilder b37183 = new StringBuilder(a37183); // stick in stringbuilder - b37183.append(" SafeStuff"); // append some safe content - b37183.replace( - b37183.length() - "Chars".length(), - b37183.length(), - "Chars"); // replace some of the end content - java.util.HashMap map37183 = new java.util.HashMap(); - map37183.put("key37183", b37183.toString()); // put in a collection - String c37183 = (String) map37183.get("key37183"); // get it back out - String d37183 = c37183.substring(0, c37183.length() - 1); // extract most of it - String e37183 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d37183.getBytes()))); // B64 encode and decode it - String f37183 = e37183.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g37183 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g37183); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01845.java b/OWASP DATASET CLEANED/BenchmarkTest01845.java deleted file mode 100644 index 2578510a3c4833d5de851fc7e9c63691f5f587c0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01845.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01845") -public class BenchmarkTest01845 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01845", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-02/BenchmarkTest01845.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01845")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01846.java b/OWASP DATASET CLEANED/BenchmarkTest01846.java deleted file mode 100644 index eca48bdbb97321fe68c64044e3187c2839122752..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01846.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01846") -public class BenchmarkTest01846 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01846", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-02/BenchmarkTest01846.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01846")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01847.java b/OWASP DATASET CLEANED/BenchmarkTest01847.java deleted file mode 100644 index 37d64465a21cbcc8569a2f05ace6c5918cf658f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01847.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01847") -public class BenchmarkTest01847 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01847", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-02/BenchmarkTest01847.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01847")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01848.java b/OWASP DATASET CLEANED/BenchmarkTest01848.java deleted file mode 100644 index ad777035c99b8c45c7d47bb3e6c57d86c58c94c6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01848.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01848") -public class BenchmarkTest01848 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01848", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-02/BenchmarkTest01848.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01848")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01849.java b/OWASP DATASET CLEANED/BenchmarkTest01849.java deleted file mode 100644 index 0eb8373036058bf2c874e1e8466fd091bd3e6e70..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01849.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01849") -public class BenchmarkTest01849 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01849", "someSecret"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/hash-02/BenchmarkTest01849.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01849")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a45344 = param; // assign - StringBuilder b45344 = new StringBuilder(a45344); // stick in stringbuilder - b45344.append(" SafeStuff"); // append some safe content - b45344.replace( - b45344.length() - "Chars".length(), - b45344.length(), - "Chars"); // replace some of the end content - java.util.HashMap map45344 = new java.util.HashMap(); - map45344.put("key45344", b45344.toString()); // put in a collection - String c45344 = (String) map45344.get("key45344"); // get it back out - String d45344 = c45344.substring(0, c45344.length() - 1); // extract most of it - String e45344 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d45344.getBytes()))); // B64 encode and decode it - String f45344 = e45344.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g45344 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g45344); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01850.java b/OWASP DATASET CLEANED/BenchmarkTest01850.java deleted file mode 100644 index b38e94d618ee8f852a29473d4a92f12828ea3f03..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01850.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01850") -public class BenchmarkTest01850 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01850", "ECHOOO"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-02/BenchmarkTest01850.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01850")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01851.java b/OWASP DATASET CLEANED/BenchmarkTest01851.java deleted file mode 100644 index 85be124f989be752cea3a4d1210332de45390e16..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01851.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01851") -public class BenchmarkTest01851 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01851", "ECHOOO"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-02/BenchmarkTest01851.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01851")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01852.java b/OWASP DATASET CLEANED/BenchmarkTest01852.java deleted file mode 100644 index 6cc163c503d65766a61d5bf897b07195b69f963e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01852.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01852") -public class BenchmarkTest01852 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01852", "ECHOOO"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-02/BenchmarkTest01852.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01852")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01853.java b/OWASP DATASET CLEANED/BenchmarkTest01853.java deleted file mode 100644 index 643a9aeddf89c8346b1aa10d43ee6dc07fe00fdc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01853.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01853") -public class BenchmarkTest01853 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01853", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01853.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01853")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01854.java b/OWASP DATASET CLEANED/BenchmarkTest01854.java deleted file mode 100644 index a1d7a89fe8b0f65d9e321692ad5b8283c2b08a55..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01854.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01854") -public class BenchmarkTest01854 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01854", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01854.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01854")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a34242 = param; // assign - StringBuilder b34242 = new StringBuilder(a34242); // stick in stringbuilder - b34242.append(" SafeStuff"); // append some safe content - b34242.replace( - b34242.length() - "Chars".length(), - b34242.length(), - "Chars"); // replace some of the end content - java.util.HashMap map34242 = new java.util.HashMap(); - map34242.put("key34242", b34242.toString()); // put in a collection - String c34242 = (String) map34242.get("key34242"); // get it back out - String d34242 = c34242.substring(0, c34242.length() - 1); // extract most of it - String e34242 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d34242.getBytes()))); // B64 encode and decode it - String f34242 = e34242.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g34242 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g34242); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01855.java b/OWASP DATASET CLEANED/BenchmarkTest01855.java deleted file mode 100644 index d49fd5d4a105e8a6e2113a2b2a471666dd1d21d8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01855.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01855") -public class BenchmarkTest01855 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01855", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01855.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01855")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01856.java b/OWASP DATASET CLEANED/BenchmarkTest01856.java deleted file mode 100644 index aaf7bbac2ae380dcc03544a32132772e87ebb41e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01856.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01856") -public class BenchmarkTest01856 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01856", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01856.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01856")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01857.java b/OWASP DATASET CLEANED/BenchmarkTest01857.java deleted file mode 100644 index 8598803d2bbd6f2c9421ee48949bdcdfcfdbcdcd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01857.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01857") -public class BenchmarkTest01857 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01857", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01857.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01857")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01858.java b/OWASP DATASET CLEANED/BenchmarkTest01858.java deleted file mode 100644 index 607a500c9ebfc90d721b17f85fdc2de6e23e1c67..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01858.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01858") -public class BenchmarkTest01858 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01858", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01858.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01858")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map95052 = new java.util.HashMap(); - map95052.put("keyA-95052", "a_Value"); // put some stuff in the collection - map95052.put("keyB-95052", param); // put it in a collection - map95052.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map95052.get("keyB-95052"); // get it back out - bar = (String) map95052.get("keyA-95052"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01859.java b/OWASP DATASET CLEANED/BenchmarkTest01859.java deleted file mode 100644 index 8567931dd0cdf2975b9cd6363aa8519d114a55e6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01859.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01859") -public class BenchmarkTest01859 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01859", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01859.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01859")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01860.java b/OWASP DATASET CLEANED/BenchmarkTest01860.java deleted file mode 100644 index 85f530e06fecdd85070a7195ca2b566c2eba00ad..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01860.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01860") -public class BenchmarkTest01860 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01860", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01860.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01860")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01861.java b/OWASP DATASET CLEANED/BenchmarkTest01861.java deleted file mode 100644 index eed2e87d020246acbc9fd6d1bb7015cba072c864..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01861.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01861") -public class BenchmarkTest01861 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01861", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/securecookie-00/BenchmarkTest01861.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01861")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01862.java b/OWASP DATASET CLEANED/BenchmarkTest01862.java deleted file mode 100644 index acfe2945bf630f04550cce62e8c2d4476bebf6f3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01862.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01862") -public class BenchmarkTest01862 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01862", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/securecookie-00/BenchmarkTest01862.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01862")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01863.java b/OWASP DATASET CLEANED/BenchmarkTest01863.java deleted file mode 100644 index 2378cbabea281b52f0e3edde565dc43e89d847e0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01863.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01863") -public class BenchmarkTest01863 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01863", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/securecookie-00/BenchmarkTest01863.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01863")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01864.java b/OWASP DATASET CLEANED/BenchmarkTest01864.java deleted file mode 100644 index 28a4a7b34cf9aebfb41694060bf1c57b5c9057fd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01864.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01864") -public class BenchmarkTest01864 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01864", "ls"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-02/BenchmarkTest01864.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01864")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01865.java b/OWASP DATASET CLEANED/BenchmarkTest01865.java deleted file mode 100644 index 0da0955c2a51c3b648879ea8568fa9125c2e902f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01865.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01865") -public class BenchmarkTest01865 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01865", "ls"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/cmdi-02/BenchmarkTest01865.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01865")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01866.java b/OWASP DATASET CLEANED/BenchmarkTest01866.java deleted file mode 100644 index ee1eb6e0b1928795f4dbad50d0c3b53cc62eedb5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01866.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01866") -public class BenchmarkTest01866 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01866", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01866.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01866")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01867.java b/OWASP DATASET CLEANED/BenchmarkTest01867.java deleted file mode 100644 index e678175587dca3b9d0277176ef7d8d32317caecd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01867.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01867") -public class BenchmarkTest01867 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01867", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01867.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01867")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map94996 = new java.util.HashMap(); - map94996.put("keyA-94996", "a_Value"); // put some stuff in the collection - map94996.put("keyB-94996", param); // put it in a collection - map94996.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map94996.get("keyB-94996"); // get it back out - bar = (String) map94996.get("keyA-94996"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01868.java b/OWASP DATASET CLEANED/BenchmarkTest01868.java deleted file mode 100644 index 8535147c8699c730a1a17f1d304cee53bfa60275..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01868.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01868") -public class BenchmarkTest01868 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01868", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01868.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01868")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01869.java b/OWASP DATASET CLEANED/BenchmarkTest01869.java deleted file mode 100644 index a0b75ba57515235e20356c86b75cfab12936b384..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01869.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01869") -public class BenchmarkTest01869 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01869", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01869.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01869")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01870.java b/OWASP DATASET CLEANED/BenchmarkTest01870.java deleted file mode 100644 index 323eab57343232179bb67871c3b53f6e532c713f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01870.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01870") -public class BenchmarkTest01870 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01870", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01870.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01870")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01871.java b/OWASP DATASET CLEANED/BenchmarkTest01871.java deleted file mode 100644 index acb918ff018eb7b0de0a734a3b05cfba6ad1227b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01871.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01871") -public class BenchmarkTest01871 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01871", "whatever"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/weakrand-04/BenchmarkTest01871.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01871")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz52473 = new StringBuilder(param); - bar = sbxyz52473.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01872.java b/OWASP DATASET CLEANED/BenchmarkTest01872.java deleted file mode 100644 index de4d068f4f1998cff44f94a57265787769ab5134..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01872.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01872") -public class BenchmarkTest01872 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01872", "color"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-01/BenchmarkTest01872.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01872")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01873.java b/OWASP DATASET CLEANED/BenchmarkTest01873.java deleted file mode 100644 index d1fe1addcad9dad09aa5e8fd0f32a9fe2791c1f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01873.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01873") -public class BenchmarkTest01873 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01873", "my_user_id"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-01/BenchmarkTest01873.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01873")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01874.java b/OWASP DATASET CLEANED/BenchmarkTest01874.java deleted file mode 100644 index 1a0f62d4283fa0a13dfdadf4e0058c794f9c5352..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01874.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01874") -public class BenchmarkTest01874 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01874", "color"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-01/BenchmarkTest01874.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01874")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01875.java b/OWASP DATASET CLEANED/BenchmarkTest01875.java deleted file mode 100644 index 20914fbee14ec34ee2433eadb31eedd87a966f0a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01875.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01875") -public class BenchmarkTest01875 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01875", "color"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-01/BenchmarkTest01875.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01875")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01876.java b/OWASP DATASET CLEANED/BenchmarkTest01876.java deleted file mode 100644 index a210e4b6231850f1969f5c5232f62b96eabe4e7f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01876.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01876") -public class BenchmarkTest01876 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01876", "my_userid"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/trustbound-01/BenchmarkTest01876.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01876")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01877.java b/OWASP DATASET CLEANED/BenchmarkTest01877.java deleted file mode 100644 index 8d95fb5adc3135a791c2c583475f517774fcea40..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01877.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01877") -public class BenchmarkTest01877 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie( - "BenchmarkTest01877", "verifyUserPassword%28%27foo%27%2C%27bar%27%29"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01877.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01877")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01878.java b/OWASP DATASET CLEANED/BenchmarkTest01878.java deleted file mode 100644 index 7b63716dc1851a1a0f961302fdd7f281151a4a83..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01878.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01878") -public class BenchmarkTest01878 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01878", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01878.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01878")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01879.java b/OWASP DATASET CLEANED/BenchmarkTest01879.java deleted file mode 100644 index c2d2741ef9ef7f52d9ce9a142937584c9981953a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01879.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01879") -public class BenchmarkTest01879 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01879", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01879.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01879")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01880.java b/OWASP DATASET CLEANED/BenchmarkTest01880.java deleted file mode 100644 index e646cf220a58c084b3fb33dec6dc127ce9d38912..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01880.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01880") -public class BenchmarkTest01880 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01880", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01880.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01880")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map99153 = new java.util.HashMap(); - map99153.put("keyA-99153", "a_Value"); // put some stuff in the collection - map99153.put("keyB-99153", param); // put it in a collection - map99153.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map99153.get("keyB-99153"); // get it back out - bar = (String) map99153.get("keyA-99153"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01881.java b/OWASP DATASET CLEANED/BenchmarkTest01881.java deleted file mode 100644 index 6f7c44a9961317b5571c7576fd59288346b0f221..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01881.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01881") -public class BenchmarkTest01881 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01881", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01881.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01881")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map20027 = new java.util.HashMap(); - map20027.put("keyA-20027", "a-Value"); // put some stuff in the collection - map20027.put("keyB-20027", param); // put it in a collection - map20027.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map20027.get("keyB-20027"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01882.java b/OWASP DATASET CLEANED/BenchmarkTest01882.java deleted file mode 100644 index 2066b1af92e383a093dbd91e6fbf50a4a8db4d25..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01882.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01882") -public class BenchmarkTest01882 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01882", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01882.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01882")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map67948 = new java.util.HashMap(); - map67948.put("keyA-67948", "a-Value"); // put some stuff in the collection - map67948.put("keyB-67948", param); // put it in a collection - map67948.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map67948.get("keyB-67948"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01883.java b/OWASP DATASET CLEANED/BenchmarkTest01883.java deleted file mode 100644 index 855c25e9d443f1996cceeb49097445908201664d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01883.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01883") -public class BenchmarkTest01883 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01883", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01883.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01883")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01884.java b/OWASP DATASET CLEANED/BenchmarkTest01884.java deleted file mode 100644 index 70f8019f524339610ec41f458040ff1cf4fa1db6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01884.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01884") -public class BenchmarkTest01884 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01884", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01884.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01884")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01885.java b/OWASP DATASET CLEANED/BenchmarkTest01885.java deleted file mode 100644 index b36571c9e4a1b9e3f901886016d4f089ca987bcf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01885.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01885") -public class BenchmarkTest01885 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01885", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01885.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01885")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01886.java b/OWASP DATASET CLEANED/BenchmarkTest01886.java deleted file mode 100644 index e6b384a110be202c1acac7d6197c4ebbe90c59e7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01886.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01886") -public class BenchmarkTest01886 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01886", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01886.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01886")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a16884 = param; // assign - StringBuilder b16884 = new StringBuilder(a16884); // stick in stringbuilder - b16884.append(" SafeStuff"); // append some safe content - b16884.replace( - b16884.length() - "Chars".length(), - b16884.length(), - "Chars"); // replace some of the end content - java.util.HashMap map16884 = new java.util.HashMap(); - map16884.put("key16884", b16884.toString()); // put in a collection - String c16884 = (String) map16884.get("key16884"); // get it back out - String d16884 = c16884.substring(0, c16884.length() - 1); // extract most of it - String e16884 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d16884.getBytes()))); // B64 encode and decode it - String f16884 = e16884.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g16884 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g16884); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01887.java b/OWASP DATASET CLEANED/BenchmarkTest01887.java deleted file mode 100644 index 673748a6804ea40a39e55f142134ea6856dbc5f1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01887.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01887") -public class BenchmarkTest01887 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01887", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01887.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01887")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01888.java b/OWASP DATASET CLEANED/BenchmarkTest01888.java deleted file mode 100644 index e671b2c4d54382582e1a5e6bc85f8a0f09ffed0d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01888.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01888") -public class BenchmarkTest01888 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01888", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01888.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01888")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01889.java b/OWASP DATASET CLEANED/BenchmarkTest01889.java deleted file mode 100644 index cbea08b093bf7882ba8bc6980c9c906fa6dc1766..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01889.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01889") -public class BenchmarkTest01889 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01889", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01889.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01889")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01890.java b/OWASP DATASET CLEANED/BenchmarkTest01890.java deleted file mode 100644 index cf86030798eaab30d68cca96aa0c909f6aac985a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01890.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01890") -public class BenchmarkTest01890 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01890", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01890.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01890")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01891.java b/OWASP DATASET CLEANED/BenchmarkTest01891.java deleted file mode 100644 index c2f0c2122823ec75e71ff4151e5b77feeba368ab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01891.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01891") -public class BenchmarkTest01891 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01891", "bar"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/sqli-04/BenchmarkTest01891.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01891")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01892.java b/OWASP DATASET CLEANED/BenchmarkTest01892.java deleted file mode 100644 index 63890fb1f2678626c9f86f6b963d2e41cbb3b112..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01892.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01892") -public class BenchmarkTest01892 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01892", "2222"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/xpathi-00/BenchmarkTest01892.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01892")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map3451 = new java.util.HashMap(); - map3451.put("keyA-3451", "a-Value"); // put some stuff in the collection - map3451.put("keyB-3451", param); // put it in a collection - map3451.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map3451.get("keyB-3451"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01893.java b/OWASP DATASET CLEANED/BenchmarkTest01893.java deleted file mode 100644 index 096f5cf18d41f117cd9fedd398baa4f4cfe66216..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01893.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01893") -public class BenchmarkTest01893 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01893", "2222"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/xpathi-00/BenchmarkTest01893.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01893")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01894.java b/OWASP DATASET CLEANED/BenchmarkTest01894.java deleted file mode 100644 index 313a19b02e2ef0e95b55dbb9bc5b68d6a57a10a2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01894.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01894") -public class BenchmarkTest01894 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - javax.servlet.http.Cookie userCookie = - new javax.servlet.http.Cookie("BenchmarkTest01894", "2222"); - userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes - userCookie.setSecure(true); - userCookie.setPath(request.getRequestURI()); - userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - response.addCookie(userCookie); - javax.servlet.RequestDispatcher rd = - request.getRequestDispatcher("/xpathi-00/BenchmarkTest01894.html"); - rd.include(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - javax.servlet.http.Cookie[] theCookies = request.getCookies(); - - String param = "noCookieValueSupplied"; - if (theCookies != null) { - for (javax.servlet.http.Cookie theCookie : theCookies) { - if (theCookie.getName().equals("BenchmarkTest01894")) { - param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); - break; - } - } - } - - String bar = doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01895.java b/OWASP DATASET CLEANED/BenchmarkTest01895.java deleted file mode 100644 index 99b7e8dcc3863744df4d7d6ee923444fdc317749..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01895.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01895") -public class BenchmarkTest01895 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01895") != null) { - param = request.getHeader("BenchmarkTest01895"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01896.java b/OWASP DATASET CLEANED/BenchmarkTest01896.java deleted file mode 100644 index 8088a532d000f56535167e214129194ebeb40d8f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01896.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01896") -public class BenchmarkTest01896 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01896") != null) { - param = request.getHeader("BenchmarkTest01896"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01897.java b/OWASP DATASET CLEANED/BenchmarkTest01897.java deleted file mode 100644 index 9dbd8b67f81e72dfb63aeacf97c866c72c6cf3fe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01897.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01897") -public class BenchmarkTest01897 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01897") != null) { - param = request.getHeader("BenchmarkTest01897"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01898.java b/OWASP DATASET CLEANED/BenchmarkTest01898.java deleted file mode 100644 index 5970ed6658dac19628d354a62d9b95e21eaa89dc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01898.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01898") -public class BenchmarkTest01898 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01898") != null) { - param = request.getHeader("BenchmarkTest01898"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01899.java b/OWASP DATASET CLEANED/BenchmarkTest01899.java deleted file mode 100644 index dff3dbf555a3f2e4628e03e16ea5cd664e70428c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01899.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01899") -public class BenchmarkTest01899 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01899") != null) { - param = request.getHeader("BenchmarkTest01899"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01900.java b/OWASP DATASET CLEANED/BenchmarkTest01900.java deleted file mode 100644 index 4160375312414c52dc55045cd2fb1fb1893dc495..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01900.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01900") -public class BenchmarkTest01900 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01900") != null) { - param = request.getHeader("BenchmarkTest01900"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01901.java b/OWASP DATASET CLEANED/BenchmarkTest01901.java deleted file mode 100644 index 0fd49d479debd6e5474d0b789dee1db645e2ca73..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01901.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01901") -public class BenchmarkTest01901 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01901") != null) { - param = request.getHeader("BenchmarkTest01901"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz69308 = new StringBuilder(param); - String bar = sbxyz69308.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01902.java b/OWASP DATASET CLEANED/BenchmarkTest01902.java deleted file mode 100644 index 3544dfadb6e1d01fd18ca10fadeae039d8b389dc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01902.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01902") -public class BenchmarkTest01902 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01902") != null) { - param = request.getHeader("BenchmarkTest01902"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01903.java b/OWASP DATASET CLEANED/BenchmarkTest01903.java deleted file mode 100644 index 6a66aa2cba52ae1a6184128fa1f36784acf1fa81..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01903.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01903") -public class BenchmarkTest01903 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01903") != null) { - param = request.getHeader("BenchmarkTest01903"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01904.java b/OWASP DATASET CLEANED/BenchmarkTest01904.java deleted file mode 100644 index 6f9397cb21e4437eab6c0079ac0fa2068b3a428c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01904.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01904") -public class BenchmarkTest01904 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01904") != null) { - param = request.getHeader("BenchmarkTest01904"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map13742 = new java.util.HashMap(); - map13742.put("keyA-13742", "a-Value"); // put some stuff in the collection - map13742.put("keyB-13742", param); // put it in a collection - map13742.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map13742.get("keyB-13742"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01905.java b/OWASP DATASET CLEANED/BenchmarkTest01905.java deleted file mode 100644 index d7b30267ee72eeb9465351a3751638213ab392fa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01905.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01905") -public class BenchmarkTest01905 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01905") != null) { - param = request.getHeader("BenchmarkTest01905"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map33587 = new java.util.HashMap(); - map33587.put("keyA-33587", "a_Value"); // put some stuff in the collection - map33587.put("keyB-33587", param); // put it in a collection - map33587.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map33587.get("keyB-33587"); // get it back out - bar = (String) map33587.get("keyA-33587"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01906.java b/OWASP DATASET CLEANED/BenchmarkTest01906.java deleted file mode 100644 index 100a7aa944f45b7c6cad3f0de8325791fe6a2d15..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01906.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01906") -public class BenchmarkTest01906 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01906") != null) { - param = request.getHeader("BenchmarkTest01906"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01907.java b/OWASP DATASET CLEANED/BenchmarkTest01907.java deleted file mode 100644 index 9a3581bb0aa1255e5a6b126263036762b2f57e1e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01907.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01907") -public class BenchmarkTest01907 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01907") != null) { - param = request.getHeader("BenchmarkTest01907"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01908.java b/OWASP DATASET CLEANED/BenchmarkTest01908.java deleted file mode 100644 index fb1703a709e8c711f2d53e30fdd87af34c5f9de9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01908.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01908") -public class BenchmarkTest01908 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01908") != null) { - param = request.getHeader("BenchmarkTest01908"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01909.java b/OWASP DATASET CLEANED/BenchmarkTest01909.java deleted file mode 100644 index f1f0a22c783483786d74d13078c02c5ba8138917..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01909.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest01909") -public class BenchmarkTest01909 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01909") != null) { - param = request.getHeader("BenchmarkTest01909"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map30748 = new java.util.HashMap(); - map30748.put("keyA-30748", "a_Value"); // put some stuff in the collection - map30748.put("keyB-30748", param); // put it in a collection - map30748.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map30748.get("keyB-30748"); // get it back out - bar = (String) map30748.get("keyA-30748"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01910.java b/OWASP DATASET CLEANED/BenchmarkTest01910.java deleted file mode 100644 index cab0943a447f8571f596512a21c4fdbc1908e757..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01910.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01910") -public class BenchmarkTest01910 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01910") != null) { - param = request.getHeader("BenchmarkTest01910"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01911.java b/OWASP DATASET CLEANED/BenchmarkTest01911.java deleted file mode 100644 index f5e4a857ebf92a1aa0597be4b11c765eb073a85a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01911.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01911") -public class BenchmarkTest01911 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01911") != null) { - param = request.getHeader("BenchmarkTest01911"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01912.java b/OWASP DATASET CLEANED/BenchmarkTest01912.java deleted file mode 100644 index 87e50b9ed76182ef89021c8dc66add0717bd7a3b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01912.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01912") -public class BenchmarkTest01912 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01912") != null) { - param = request.getHeader("BenchmarkTest01912"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01913.java b/OWASP DATASET CLEANED/BenchmarkTest01913.java deleted file mode 100644 index d4b62ae6ad27e49908fad4be3ec20391ccf24e32..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01913.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01913") -public class BenchmarkTest01913 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01913") != null) { - param = request.getHeader("BenchmarkTest01913"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01914.java b/OWASP DATASET CLEANED/BenchmarkTest01914.java deleted file mode 100644 index 9b18cb57a2967652fa8e879fa9a49bdd3142bcb0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01914.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01914") -public class BenchmarkTest01914 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01915.java b/OWASP DATASET CLEANED/BenchmarkTest01915.java deleted file mode 100644 index fbc4d87eeaeabe7c6b618d7cd23328fe3946be47..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01915.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01915") -public class BenchmarkTest01915 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01916.java b/OWASP DATASET CLEANED/BenchmarkTest01916.java deleted file mode 100644 index 666c47ae50a389b92437b66e566796f143e4917a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01916.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01916") -public class BenchmarkTest01916 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01917.java b/OWASP DATASET CLEANED/BenchmarkTest01917.java deleted file mode 100644 index db357e8c3561d75ddb567e4e0c49b35757dcf1f1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01917.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01917") -public class BenchmarkTest01917 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01918.java b/OWASP DATASET CLEANED/BenchmarkTest01918.java deleted file mode 100644 index a374d4cf8407f297e8ef79e1ed6d63f839649267..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01918.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01918") -public class BenchmarkTest01918 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01919.java b/OWASP DATASET CLEANED/BenchmarkTest01919.java deleted file mode 100644 index 64d4a8caaf7fdda6c079b2ee2ce602904c4d9dff..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01919.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01919") -public class BenchmarkTest01919 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01920.java b/OWASP DATASET CLEANED/BenchmarkTest01920.java deleted file mode 100644 index 8649d0565805efc14ceeff245f6b520b16855b99..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01920.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01920") -public class BenchmarkTest01920 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01921.java b/OWASP DATASET CLEANED/BenchmarkTest01921.java deleted file mode 100644 index 55e3148e9be5977f0d7e604a900b669bbddb33ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01921.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01921") -public class BenchmarkTest01921 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01922.java b/OWASP DATASET CLEANED/BenchmarkTest01922.java deleted file mode 100644 index e8c5473b89515398a823b8ba6716a1120420d7e4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01922.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01922") -public class BenchmarkTest01922 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01923.java b/OWASP DATASET CLEANED/BenchmarkTest01923.java deleted file mode 100644 index a420911097a390a73c4580135c7fb2158fbb40c4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01923.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01923") -public class BenchmarkTest01923 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01924.java b/OWASP DATASET CLEANED/BenchmarkTest01924.java deleted file mode 100644 index 38d579a652e1cd52a3a9b0d6e0f35fcc8c8ee925..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01924.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01924") -public class BenchmarkTest01924 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01925.java b/OWASP DATASET CLEANED/BenchmarkTest01925.java deleted file mode 100644 index 37cf6149abf50e202da5a43ab17e5e212f72cd2f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01925.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01925") -public class BenchmarkTest01925 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz28389 = new StringBuilder(param); - bar = sbxyz28389.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01926.java b/OWASP DATASET CLEANED/BenchmarkTest01926.java deleted file mode 100644 index 99ea3c819f6b8609a86fdcbf189326d47414254a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01926.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01926") -public class BenchmarkTest01926 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01927.java b/OWASP DATASET CLEANED/BenchmarkTest01927.java deleted file mode 100644 index 78804f1fd0611901618fd0370b5310c2a3040a45..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01927.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest01927") -public class BenchmarkTest01927 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("Referer") != null) { - param = request.getHeader("Referer"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01928.java b/OWASP DATASET CLEANED/BenchmarkTest01928.java deleted file mode 100644 index 46fab42eb3b7b8464cbce91658f10268a765bfb4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01928.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01928") -public class BenchmarkTest01928 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01928") != null) { - param = request.getHeader("BenchmarkTest01928"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01929.java b/OWASP DATASET CLEANED/BenchmarkTest01929.java deleted file mode 100644 index 2f57490b5fda685cb4c640a755a33f2fd10462b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01929.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01929") -public class BenchmarkTest01929 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01929") != null) { - param = request.getHeader("BenchmarkTest01929"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map44 = new java.util.HashMap(); - map44.put("keyA-44", "a-Value"); // put some stuff in the collection - map44.put("keyB-44", param); // put it in a collection - map44.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map44.get("keyB-44"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01930.java b/OWASP DATASET CLEANED/BenchmarkTest01930.java deleted file mode 100644 index dd89857f17346173310847a6a0dc18beea74e29d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01930.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01930") -public class BenchmarkTest01930 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01930") != null) { - param = request.getHeader("BenchmarkTest01930"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz62502 = new StringBuilder(param); - String bar = sbxyz62502.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01931.java b/OWASP DATASET CLEANED/BenchmarkTest01931.java deleted file mode 100644 index 80dfb24de3403222e7a030b62084407347cd26e1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01931.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01931") -public class BenchmarkTest01931 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01931") != null) { - param = request.getHeader("BenchmarkTest01931"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a40465 = param; // assign - StringBuilder b40465 = new StringBuilder(a40465); // stick in stringbuilder - b40465.append(" SafeStuff"); // append some safe content - b40465.replace( - b40465.length() - "Chars".length(), - b40465.length(), - "Chars"); // replace some of the end content - java.util.HashMap map40465 = new java.util.HashMap(); - map40465.put("key40465", b40465.toString()); // put in a collection - String c40465 = (String) map40465.get("key40465"); // get it back out - String d40465 = c40465.substring(0, c40465.length() - 1); // extract most of it - String e40465 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d40465.getBytes()))); // B64 encode and decode it - String f40465 = e40465.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f40465); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01932.java b/OWASP DATASET CLEANED/BenchmarkTest01932.java deleted file mode 100644 index 6368db9470c3e5ee8e1dd1c0405fba2ab86af451..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01932.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01932") -public class BenchmarkTest01932 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01932") != null) { - param = request.getHeader("BenchmarkTest01932"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01933.java b/OWASP DATASET CLEANED/BenchmarkTest01933.java deleted file mode 100644 index 5e0c0c6dcc1f7bddd844ce72b64dc0ab8bf2afdf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01933.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01933") -public class BenchmarkTest01933 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01933") != null) { - param = request.getHeader("BenchmarkTest01933"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01934.java b/OWASP DATASET CLEANED/BenchmarkTest01934.java deleted file mode 100644 index ccadfb109e1df37fcff29c0254b4102453726e1e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01934.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01934") -public class BenchmarkTest01934 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01934") != null) { - param = request.getHeader("BenchmarkTest01934"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01935.java b/OWASP DATASET CLEANED/BenchmarkTest01935.java deleted file mode 100644 index de825221aaeefb9832ae90b50b9f51fadf14a0f2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01935.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest01935") -public class BenchmarkTest01935 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01935") != null) { - param = request.getHeader("BenchmarkTest01935"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a17785 = param; // assign - StringBuilder b17785 = new StringBuilder(a17785); // stick in stringbuilder - b17785.append(" SafeStuff"); // append some safe content - b17785.replace( - b17785.length() - "Chars".length(), - b17785.length(), - "Chars"); // replace some of the end content - java.util.HashMap map17785 = new java.util.HashMap(); - map17785.put("key17785", b17785.toString()); // put in a collection - String c17785 = (String) map17785.get("key17785"); // get it back out - String d17785 = c17785.substring(0, c17785.length() - 1); // extract most of it - String e17785 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d17785.getBytes()))); // B64 encode and decode it - String f17785 = e17785.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f17785); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01936.java b/OWASP DATASET CLEANED/BenchmarkTest01936.java deleted file mode 100644 index 227611163ca93c8508adfcc10f72b9c2307ad112..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01936.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01936") -public class BenchmarkTest01936 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01936") != null) { - param = request.getHeader("BenchmarkTest01936"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01937.java b/OWASP DATASET CLEANED/BenchmarkTest01937.java deleted file mode 100644 index 2b49b37b1d53a0c445e36a192ca7c97d5477f766..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01937.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01937") -public class BenchmarkTest01937 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01937") != null) { - param = request.getHeader("BenchmarkTest01937"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01938.java b/OWASP DATASET CLEANED/BenchmarkTest01938.java deleted file mode 100644 index cdcc7d61715b75d9f3855acfbc8574589d862fb2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01938.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01938") -public class BenchmarkTest01938 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01938") != null) { - param = request.getHeader("BenchmarkTest01938"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01939.java b/OWASP DATASET CLEANED/BenchmarkTest01939.java deleted file mode 100644 index de7d62663309d3fb9fdaa58ede07b0873ba3eea3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01939.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01939") -public class BenchmarkTest01939 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01939") != null) { - param = request.getHeader("BenchmarkTest01939"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01940.java b/OWASP DATASET CLEANED/BenchmarkTest01940.java deleted file mode 100644 index aa01245f5ea1e5fc8901f011d7b0fcd4ba1796b8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01940.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01940") -public class BenchmarkTest01940 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01940") != null) { - param = request.getHeader("BenchmarkTest01940"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01941.java b/OWASP DATASET CLEANED/BenchmarkTest01941.java deleted file mode 100644 index e708e6d43a2c4c656241ae4bcfbbd4e2fc050e7d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01941.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01941") -public class BenchmarkTest01941 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01941") != null) { - param = request.getHeader("BenchmarkTest01941"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a20426 = param; // assign - StringBuilder b20426 = new StringBuilder(a20426); // stick in stringbuilder - b20426.append(" SafeStuff"); // append some safe content - b20426.replace( - b20426.length() - "Chars".length(), - b20426.length(), - "Chars"); // replace some of the end content - java.util.HashMap map20426 = new java.util.HashMap(); - map20426.put("key20426", b20426.toString()); // put in a collection - String c20426 = (String) map20426.get("key20426"); // get it back out - String d20426 = c20426.substring(0, c20426.length() - 1); // extract most of it - String e20426 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d20426.getBytes()))); // B64 encode and decode it - String f20426 = e20426.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g20426 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g20426); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01942.java b/OWASP DATASET CLEANED/BenchmarkTest01942.java deleted file mode 100644 index 5cd095dc65891d21c4f0f796bf882e2e7df4d4b1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01942.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01942") -public class BenchmarkTest01942 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01942") != null) { - param = request.getHeader("BenchmarkTest01942"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01943.java b/OWASP DATASET CLEANED/BenchmarkTest01943.java deleted file mode 100644 index a8ac3fbbac14942bbab3012da4ed264c79f29833..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01943.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01943") -public class BenchmarkTest01943 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01943") != null) { - param = request.getHeader("BenchmarkTest01943"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map72345 = new java.util.HashMap(); - map72345.put("keyA-72345", "a_Value"); // put some stuff in the collection - map72345.put("keyB-72345", param); // put it in a collection - map72345.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map72345.get("keyB-72345"); // get it back out - bar = (String) map72345.get("keyA-72345"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01944.java b/OWASP DATASET CLEANED/BenchmarkTest01944.java deleted file mode 100644 index 5db746ebc69a6e250d94d6aefa42b73e343d4c23..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01944.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest01944") -public class BenchmarkTest01944 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01944") != null) { - param = request.getHeader("BenchmarkTest01944"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01945.java b/OWASP DATASET CLEANED/BenchmarkTest01945.java deleted file mode 100644 index d8c9d557a873dca80177164e49442e52b10e88c2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01945.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01945") -public class BenchmarkTest01945 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01945") != null) { - param = request.getHeader("BenchmarkTest01945"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01946.java b/OWASP DATASET CLEANED/BenchmarkTest01946.java deleted file mode 100644 index ef185880a4b7078223b1608621ce35b3f5b083dd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01946.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01946") -public class BenchmarkTest01946 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01946") != null) { - param = request.getHeader("BenchmarkTest01946"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01947.java b/OWASP DATASET CLEANED/BenchmarkTest01947.java deleted file mode 100644 index 38579d672a2cb9c4c4d354e6939021cc21636cc3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01947.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01947") -public class BenchmarkTest01947 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01947") != null) { - param = request.getHeader("BenchmarkTest01947"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01948.java b/OWASP DATASET CLEANED/BenchmarkTest01948.java deleted file mode 100644 index 2c6646a0ed2d31560c3dc491d2f3ebbd948643f5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01948.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01948") -public class BenchmarkTest01948 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01948") != null) { - param = request.getHeader("BenchmarkTest01948"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz84277 = new StringBuilder(param); - bar = sbxyz84277.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01949.java b/OWASP DATASET CLEANED/BenchmarkTest01949.java deleted file mode 100644 index af03e941dead1a8bc1e70474645fded85fe233bf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01949.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01949") -public class BenchmarkTest01949 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01949") != null) { - param = request.getHeader("BenchmarkTest01949"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01950.java b/OWASP DATASET CLEANED/BenchmarkTest01950.java deleted file mode 100644 index caedaab27d626ca508cf47714239d1dfe64ca5a7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01950.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01950") -public class BenchmarkTest01950 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01950") != null) { - param = request.getHeader("BenchmarkTest01950"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map14411 = new java.util.HashMap(); - map14411.put("keyA-14411", "a-Value"); // put some stuff in the collection - map14411.put("keyB-14411", param); // put it in a collection - map14411.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map14411.get("keyB-14411"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01951.java b/OWASP DATASET CLEANED/BenchmarkTest01951.java deleted file mode 100644 index 255ea8884e410fede2b0f7de9c023665fdfe6571..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01951.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01951") -public class BenchmarkTest01951 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01951") != null) { - param = request.getHeader("BenchmarkTest01951"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01952.java b/OWASP DATASET CLEANED/BenchmarkTest01952.java deleted file mode 100644 index 880b17bdf8f73731a081ee633e85640a8e90249b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01952.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01952") -public class BenchmarkTest01952 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01952") != null) { - param = request.getHeader("BenchmarkTest01952"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01953.java b/OWASP DATASET CLEANED/BenchmarkTest01953.java deleted file mode 100644 index c69dc2f776401711a18c3d7f487538d710934dd6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01953.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01953") -public class BenchmarkTest01953 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01953") != null) { - param = request.getHeader("BenchmarkTest01953"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01954.java b/OWASP DATASET CLEANED/BenchmarkTest01954.java deleted file mode 100644 index ef95cb7999740731307c34b5e616a859cf64a933..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01954.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01954") -public class BenchmarkTest01954 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01954") != null) { - param = request.getHeader("BenchmarkTest01954"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01955.java b/OWASP DATASET CLEANED/BenchmarkTest01955.java deleted file mode 100644 index ab7809b741279ada49fc7350b2f476d024d80024..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01955.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01955") -public class BenchmarkTest01955 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01955") != null) { - param = request.getHeader("BenchmarkTest01955"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01956.java b/OWASP DATASET CLEANED/BenchmarkTest01956.java deleted file mode 100644 index 088ea5e2943f7f77818654b68d155208d5c9aafc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01956.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01956") -public class BenchmarkTest01956 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01956") != null) { - param = request.getHeader("BenchmarkTest01956"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01957.java b/OWASP DATASET CLEANED/BenchmarkTest01957.java deleted file mode 100644 index 9af66a89eb2191b93b3f0f59394056bea91398a7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01957.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01957") -public class BenchmarkTest01957 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01957") != null) { - param = request.getHeader("BenchmarkTest01957"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01958.java b/OWASP DATASET CLEANED/BenchmarkTest01958.java deleted file mode 100644 index 295c51eebbd2b0c32ab5c25b58ca7d248013b85d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01958.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01958") -public class BenchmarkTest01958 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01958") != null) { - param = request.getHeader("BenchmarkTest01958"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz15757 = new StringBuilder(param); - bar = sbxyz15757.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01959.java b/OWASP DATASET CLEANED/BenchmarkTest01959.java deleted file mode 100644 index 72462d0bbff0a84a0f7fbe587cf82092b992ed65..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01959.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01959") -public class BenchmarkTest01959 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01959") != null) { - param = request.getHeader("BenchmarkTest01959"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map4095 = new java.util.HashMap(); - map4095.put("keyA-4095", "a_Value"); // put some stuff in the collection - map4095.put("keyB-4095", param); // put it in a collection - map4095.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map4095.get("keyB-4095"); // get it back out - bar = (String) map4095.get("keyA-4095"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01960.java b/OWASP DATASET CLEANED/BenchmarkTest01960.java deleted file mode 100644 index 1141af57303d7f280653132fa9f85c8f26e085e3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01960.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest01960") -public class BenchmarkTest01960 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01960") != null) { - param = request.getHeader("BenchmarkTest01960"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01961.java b/OWASP DATASET CLEANED/BenchmarkTest01961.java deleted file mode 100644 index a2b2ca3ddc969f40f08c0ccba2628fd0c9a9c2ac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01961.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01961") -public class BenchmarkTest01961 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01961") != null) { - param = request.getHeader("BenchmarkTest01961"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a99523 = param; // assign - StringBuilder b99523 = new StringBuilder(a99523); // stick in stringbuilder - b99523.append(" SafeStuff"); // append some safe content - b99523.replace( - b99523.length() - "Chars".length(), - b99523.length(), - "Chars"); // replace some of the end content - java.util.HashMap map99523 = new java.util.HashMap(); - map99523.put("key99523", b99523.toString()); // put in a collection - String c99523 = (String) map99523.get("key99523"); // get it back out - String d99523 = c99523.substring(0, c99523.length() - 1); // extract most of it - String e99523 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d99523.getBytes()))); // B64 encode and decode it - String f99523 = e99523.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g99523 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g99523); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01962.java b/OWASP DATASET CLEANED/BenchmarkTest01962.java deleted file mode 100644 index 51a0bbf7de212b461adc038a074e1b67b11cbfb4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01962.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01962") -public class BenchmarkTest01962 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01962") != null) { - param = request.getHeader("BenchmarkTest01962"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01963.java b/OWASP DATASET CLEANED/BenchmarkTest01963.java deleted file mode 100644 index 7eeff79882d60eb0c07e1daf89cf65f1c1c5f7c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01963.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01963") -public class BenchmarkTest01963 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01963") != null) { - param = request.getHeader("BenchmarkTest01963"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01964.java b/OWASP DATASET CLEANED/BenchmarkTest01964.java deleted file mode 100644 index 3c306c818d490358e7170d8712981200fadc0af3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01964.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01964") -public class BenchmarkTest01964 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01964") != null) { - param = request.getHeader("BenchmarkTest01964"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01965.java b/OWASP DATASET CLEANED/BenchmarkTest01965.java deleted file mode 100644 index aaf459b0b0dfe6100c39cbfa2234c689837b4826..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01965.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01965") -public class BenchmarkTest01965 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01965") != null) { - param = request.getHeader("BenchmarkTest01965"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01966.java b/OWASP DATASET CLEANED/BenchmarkTest01966.java deleted file mode 100644 index c1c66396b848a0bc897a5a9aec481b6085b688ea..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01966.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01966") -public class BenchmarkTest01966 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01966") != null) { - param = request.getHeader("BenchmarkTest01966"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01967.java b/OWASP DATASET CLEANED/BenchmarkTest01967.java deleted file mode 100644 index 7b820cf2b10b59c3c5ebeacb86726d4dd9fb7f23..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01967.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01967") -public class BenchmarkTest01967 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01967") != null) { - param = request.getHeader("BenchmarkTest01967"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01968.java b/OWASP DATASET CLEANED/BenchmarkTest01968.java deleted file mode 100644 index f62e19045034390f867fedb4e776e7ae19306757..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01968.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01968") -public class BenchmarkTest01968 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01968") != null) { - param = request.getHeader("BenchmarkTest01968"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01969.java b/OWASP DATASET CLEANED/BenchmarkTest01969.java deleted file mode 100644 index b10477d345fd037621c05c7aa72d23bd8eec1f22..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01969.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01969") -public class BenchmarkTest01969 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01969") != null) { - param = request.getHeader("BenchmarkTest01969"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01970.java b/OWASP DATASET CLEANED/BenchmarkTest01970.java deleted file mode 100644 index ab775cb53238842f611382a0c5b23fd2e4a2fe2e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01970.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01970") -public class BenchmarkTest01970 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01970") != null) { - param = request.getHeader("BenchmarkTest01970"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01971.java b/OWASP DATASET CLEANED/BenchmarkTest01971.java deleted file mode 100644 index f964f0481b4c7d9ced3b606bf268c414f41061f3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01971.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01971") -public class BenchmarkTest01971 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01971") != null) { - param = request.getHeader("BenchmarkTest01971"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01972.java b/OWASP DATASET CLEANED/BenchmarkTest01972.java deleted file mode 100644 index e44fec95a16e431fc7943f2e378fc98d954ff8d8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01972.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01972") -public class BenchmarkTest01972 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01972") != null) { - param = request.getHeader("BenchmarkTest01972"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01973.java b/OWASP DATASET CLEANED/BenchmarkTest01973.java deleted file mode 100644 index 4f773d5724fd92f009690d024deabdf0d86f2752..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01973.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest01973") -public class BenchmarkTest01973 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01973") != null) { - param = request.getHeader("BenchmarkTest01973"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01974.java b/OWASP DATASET CLEANED/BenchmarkTest01974.java deleted file mode 100644 index c8da4a6c016898873d26558654543605078cdd25..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01974.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest01974") -public class BenchmarkTest01974 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - if (request.getHeader("BenchmarkTest01974") != null) { - param = request.getHeader("BenchmarkTest01974"); - } - - // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map11821 = new java.util.HashMap(); - map11821.put("keyA-11821", "a-Value"); // put some stuff in the collection - map11821.put("keyB-11821", param); // put it in a collection - map11821.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map11821.get("keyB-11821"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01975.java b/OWASP DATASET CLEANED/BenchmarkTest01975.java deleted file mode 100644 index 20a2bdfc985ead5c67e660b6181fd9799201b638..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01975.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01975") -public class BenchmarkTest01975 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01976.java b/OWASP DATASET CLEANED/BenchmarkTest01976.java deleted file mode 100644 index 768c995b65ede86d80b5652bf528b51e5f50fb4d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01976.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01976") -public class BenchmarkTest01976 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz47784 = new StringBuilder(param); - String bar = sbxyz47784.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01977.java b/OWASP DATASET CLEANED/BenchmarkTest01977.java deleted file mode 100644 index 1b514e109e4f43a9ba9d69e11ecf81b547fcdecb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01977.java +++ /dev/null @@ -1,191 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01977") -public class BenchmarkTest01977 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01978.java b/OWASP DATASET CLEANED/BenchmarkTest01978.java deleted file mode 100644 index 60356599ede2ddd1e9c3901454a7866944841922..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01978.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01978") -public class BenchmarkTest01978 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz6576 = new StringBuilder(param); - bar = sbxyz6576.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01979.java b/OWASP DATASET CLEANED/BenchmarkTest01979.java deleted file mode 100644 index bf45d44addce6bb3e37e30a259d53b97e0f91dfb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01979.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01979") -public class BenchmarkTest01979 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01980.java b/OWASP DATASET CLEANED/BenchmarkTest01980.java deleted file mode 100644 index fd973924983f2315b5cba983f54973eef7c90e59..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01980.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01980") -public class BenchmarkTest01980 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz90777 = new StringBuilder(param); - String bar = sbxyz90777.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01981.java b/OWASP DATASET CLEANED/BenchmarkTest01981.java deleted file mode 100644 index 07a5fae931a04ba6f22117705963fea7ed9c2bf1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01981.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01981") -public class BenchmarkTest01981 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01982.java b/OWASP DATASET CLEANED/BenchmarkTest01982.java deleted file mode 100644 index 29ba46791619b2794271d76252b8b960928af760..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01982.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest01982") -public class BenchmarkTest01982 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01983.java b/OWASP DATASET CLEANED/BenchmarkTest01983.java deleted file mode 100644 index f3785d5db31aba5f351798d04fa64c4fab8ed41d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01983.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01983") -public class BenchmarkTest01983 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01984.java b/OWASP DATASET CLEANED/BenchmarkTest01984.java deleted file mode 100644 index 5323f7896a5f4000ccf5b78b41e334ddf2035dab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01984.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01984") -public class BenchmarkTest01984 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map95438 = new java.util.HashMap(); - map95438.put("keyA-95438", "a_Value"); // put some stuff in the collection - map95438.put("keyB-95438", param); // put it in a collection - map95438.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map95438.get("keyB-95438"); // get it back out - bar = (String) map95438.get("keyA-95438"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01985.java b/OWASP DATASET CLEANED/BenchmarkTest01985.java deleted file mode 100644 index 714fb4b6608633773a0f71a8ad4febe7b1d4bed6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01985.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01985") -public class BenchmarkTest01985 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01986.java b/OWASP DATASET CLEANED/BenchmarkTest01986.java deleted file mode 100644 index 64b33964b723520d494a0202c4cdbf12803be7e4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01986.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01986") -public class BenchmarkTest01986 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map83331 = new java.util.HashMap(); - map83331.put("keyA-83331", "a_Value"); // put some stuff in the collection - map83331.put("keyB-83331", param); // put it in a collection - map83331.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map83331.get("keyB-83331"); // get it back out - bar = (String) map83331.get("keyA-83331"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01987.java b/OWASP DATASET CLEANED/BenchmarkTest01987.java deleted file mode 100644 index 9235d51000c06de124e9f2d6be69d22be15c6a24..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01987.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01987") -public class BenchmarkTest01987 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01988.java b/OWASP DATASET CLEANED/BenchmarkTest01988.java deleted file mode 100644 index 9e6ca2e53d255799e1d88076246f6080699dbe24..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01988.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01988") -public class BenchmarkTest01988 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01989.java b/OWASP DATASET CLEANED/BenchmarkTest01989.java deleted file mode 100644 index e4bf811cb242ae4e14ee7691b6bd6a2b80867f74..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01989.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01989") -public class BenchmarkTest01989 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01990.java b/OWASP DATASET CLEANED/BenchmarkTest01990.java deleted file mode 100644 index 39b00e56161992ddd9f13adec6b151eda9ed4d51..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01990.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01990") -public class BenchmarkTest01990 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01991.java b/OWASP DATASET CLEANED/BenchmarkTest01991.java deleted file mode 100644 index afb4f0c58e7dff46f96c9ba6e408bb045e569f36..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01991.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest01991") -public class BenchmarkTest01991 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a81108 = param; // assign - StringBuilder b81108 = new StringBuilder(a81108); // stick in stringbuilder - b81108.append(" SafeStuff"); // append some safe content - b81108.replace( - b81108.length() - "Chars".length(), - b81108.length(), - "Chars"); // replace some of the end content - java.util.HashMap map81108 = new java.util.HashMap(); - map81108.put("key81108", b81108.toString()); // put in a collection - String c81108 = (String) map81108.get("key81108"); // get it back out - String d81108 = c81108.substring(0, c81108.length() - 1); // extract most of it - String e81108 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d81108.getBytes()))); // B64 encode and decode it - String f81108 = e81108.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g81108 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g81108); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01992.java b/OWASP DATASET CLEANED/BenchmarkTest01992.java deleted file mode 100644 index 55d54cb55c04f4373de3aafc8d0f50a54e0bd9bc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01992.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01992") -public class BenchmarkTest01992 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a82010 = param; // assign - StringBuilder b82010 = new StringBuilder(a82010); // stick in stringbuilder - b82010.append(" SafeStuff"); // append some safe content - b82010.replace( - b82010.length() - "Chars".length(), - b82010.length(), - "Chars"); // replace some of the end content - java.util.HashMap map82010 = new java.util.HashMap(); - map82010.put("key82010", b82010.toString()); // put in a collection - String c82010 = (String) map82010.get("key82010"); // get it back out - String d82010 = c82010.substring(0, c82010.length() - 1); // extract most of it - String e82010 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d82010.getBytes()))); // B64 encode and decode it - String f82010 = e82010.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f82010); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01993.java b/OWASP DATASET CLEANED/BenchmarkTest01993.java deleted file mode 100644 index 871a5471f255a8da88da64ff90fe6f936df24177..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01993.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01993") -public class BenchmarkTest01993 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01994.java b/OWASP DATASET CLEANED/BenchmarkTest01994.java deleted file mode 100644 index 69e82bb6696e65aadb6f9f17cbbebd82c2af068c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01994.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01994") -public class BenchmarkTest01994 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01995.java b/OWASP DATASET CLEANED/BenchmarkTest01995.java deleted file mode 100644 index 8458c41a799a4b2b3eb850e805eb9920c788e3bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01995.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01995") -public class BenchmarkTest01995 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a33633 = param; // assign - StringBuilder b33633 = new StringBuilder(a33633); // stick in stringbuilder - b33633.append(" SafeStuff"); // append some safe content - b33633.replace( - b33633.length() - "Chars".length(), - b33633.length(), - "Chars"); // replace some of the end content - java.util.HashMap map33633 = new java.util.HashMap(); - map33633.put("key33633", b33633.toString()); // put in a collection - String c33633 = (String) map33633.get("key33633"); // get it back out - String d33633 = c33633.substring(0, c33633.length() - 1); // extract most of it - String e33633 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d33633.getBytes()))); // B64 encode and decode it - String f33633 = e33633.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g33633 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g33633); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01996.java b/OWASP DATASET CLEANED/BenchmarkTest01996.java deleted file mode 100644 index a3fc776e7010e05441637be139e23a9ddab2c43e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01996.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01996") -public class BenchmarkTest01996 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01997.java b/OWASP DATASET CLEANED/BenchmarkTest01997.java deleted file mode 100644 index 4d7ed738459d07c3ed56243ce3a534f413cdf2f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01997.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01997") -public class BenchmarkTest01997 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01998.java b/OWASP DATASET CLEANED/BenchmarkTest01998.java deleted file mode 100644 index 33a2e722417d07a23186fd3f31ee8f9add8a076d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01998.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest01998") -public class BenchmarkTest01998 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest01999.java b/OWASP DATASET CLEANED/BenchmarkTest01999.java deleted file mode 100644 index 39b19b3a3925785cc9976c98630884bbaaffad67..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest01999.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest01999") -public class BenchmarkTest01999 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map28743 = new java.util.HashMap(); - map28743.put("keyA-28743", "a-Value"); // put some stuff in the collection - map28743.put("keyB-28743", param); // put it in a collection - map28743.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map28743.get("keyB-28743"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02000.java b/OWASP DATASET CLEANED/BenchmarkTest02000.java deleted file mode 100644 index 0973ea2b893764684f05c62c4383199460586941..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02000.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02000") -public class BenchmarkTest02000 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02001.java b/OWASP DATASET CLEANED/BenchmarkTest02001.java deleted file mode 100644 index 770047cfc0ce5a661472387fc43e945ec6db264d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02001.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02001") -public class BenchmarkTest02001 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02002.java b/OWASP DATASET CLEANED/BenchmarkTest02002.java deleted file mode 100644 index 11e685c3eb4601541122ba4da386e31053bca09e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02002.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02002") -public class BenchmarkTest02002 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02003.java b/OWASP DATASET CLEANED/BenchmarkTest02003.java deleted file mode 100644 index 80796377fa6e98906cc77952f3608783b9125145..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02003.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02003") -public class BenchmarkTest02003 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a69278 = param; // assign - StringBuilder b69278 = new StringBuilder(a69278); // stick in stringbuilder - b69278.append(" SafeStuff"); // append some safe content - b69278.replace( - b69278.length() - "Chars".length(), - b69278.length(), - "Chars"); // replace some of the end content - java.util.HashMap map69278 = new java.util.HashMap(); - map69278.put("key69278", b69278.toString()); // put in a collection - String c69278 = (String) map69278.get("key69278"); // get it back out - String d69278 = c69278.substring(0, c69278.length() - 1); // extract most of it - String e69278 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d69278.getBytes()))); // B64 encode and decode it - String f69278 = e69278.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g69278 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g69278); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02004.java b/OWASP DATASET CLEANED/BenchmarkTest02004.java deleted file mode 100644 index 1c0c54218a470b913ebd6bdfaa7fc9129eb4b3b0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02004.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02004") -public class BenchmarkTest02004 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02005.java b/OWASP DATASET CLEANED/BenchmarkTest02005.java deleted file mode 100644 index d7dbf68655eee40935eec045c9a9ed9206ddb368..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02005.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02005") -public class BenchmarkTest02005 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map44210 = new java.util.HashMap(); - map44210.put("keyA-44210", "a-Value"); // put some stuff in the collection - map44210.put("keyB-44210", param); // put it in a collection - map44210.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map44210.get("keyB-44210"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02006.java b/OWASP DATASET CLEANED/BenchmarkTest02006.java deleted file mode 100644 index 327b4ca683c3aec433189d6f83c7091851ac9c61..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02006.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02006") -public class BenchmarkTest02006 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz44058 = new StringBuilder(param); - String bar = sbxyz44058.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02007.java b/OWASP DATASET CLEANED/BenchmarkTest02007.java deleted file mode 100644 index c8f8b611822d9ba037a0a1165e55a6379161ae57..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02007.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02007") -public class BenchmarkTest02007 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02008.java b/OWASP DATASET CLEANED/BenchmarkTest02008.java deleted file mode 100644 index d9c6eec1309c924452752068085d07c54f5c422b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02008.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02008") -public class BenchmarkTest02008 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a97712 = param; // assign - StringBuilder b97712 = new StringBuilder(a97712); // stick in stringbuilder - b97712.append(" SafeStuff"); // append some safe content - b97712.replace( - b97712.length() - "Chars".length(), - b97712.length(), - "Chars"); // replace some of the end content - java.util.HashMap map97712 = new java.util.HashMap(); - map97712.put("key97712", b97712.toString()); // put in a collection - String c97712 = (String) map97712.get("key97712"); // get it back out - String d97712 = c97712.substring(0, c97712.length() - 1); // extract most of it - String e97712 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d97712.getBytes()))); // B64 encode and decode it - String f97712 = e97712.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g97712 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g97712); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02009.java b/OWASP DATASET CLEANED/BenchmarkTest02009.java deleted file mode 100644 index 04593ea5444eb616299e15237b42c991d441a50f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02009.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02009") -public class BenchmarkTest02009 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02010.java b/OWASP DATASET CLEANED/BenchmarkTest02010.java deleted file mode 100644 index a4b849788667528c24472032d0a26ff021955cf4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02010.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02010") -public class BenchmarkTest02010 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02011.java b/OWASP DATASET CLEANED/BenchmarkTest02011.java deleted file mode 100644 index 20abd4c5674e7c6d35a00defe34874117273c31a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02011.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02011") -public class BenchmarkTest02011 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz64726 = new StringBuilder(param); - String bar = sbxyz64726.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02012.java b/OWASP DATASET CLEANED/BenchmarkTest02012.java deleted file mode 100644 index a70861186e3cee45bfa84cb8201c348c61598f2c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02012.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02012") -public class BenchmarkTest02012 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a69185 = param; // assign - StringBuilder b69185 = new StringBuilder(a69185); // stick in stringbuilder - b69185.append(" SafeStuff"); // append some safe content - b69185.replace( - b69185.length() - "Chars".length(), - b69185.length(), - "Chars"); // replace some of the end content - java.util.HashMap map69185 = new java.util.HashMap(); - map69185.put("key69185", b69185.toString()); // put in a collection - String c69185 = (String) map69185.get("key69185"); // get it back out - String d69185 = c69185.substring(0, c69185.length() - 1); // extract most of it - String e69185 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d69185.getBytes()))); // B64 encode and decode it - String f69185 = e69185.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g69185 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g69185); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02013.java b/OWASP DATASET CLEANED/BenchmarkTest02013.java deleted file mode 100644 index be09f9a6ffa3402a23b1855e216bbc40bfa4efbc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02013.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02013") -public class BenchmarkTest02013 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02014.java b/OWASP DATASET CLEANED/BenchmarkTest02014.java deleted file mode 100644 index cdf9e9eca8623e6af8e4cc4506bac36e98dc86e2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02014.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02014") -public class BenchmarkTest02014 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map37065 = new java.util.HashMap(); - map37065.put("keyA-37065", "a-Value"); // put some stuff in the collection - map37065.put("keyB-37065", param); // put it in a collection - map37065.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map37065.get("keyB-37065"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02015.java b/OWASP DATASET CLEANED/BenchmarkTest02015.java deleted file mode 100644 index 32eca8711220a512e44f08c9daaa7c2ea365d8a0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02015.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02015") -public class BenchmarkTest02015 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02016.java b/OWASP DATASET CLEANED/BenchmarkTest02016.java deleted file mode 100644 index 815987e35f3bc2458f3536bb61ee19c58d950041..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02016.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02016") -public class BenchmarkTest02016 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration names = request.getHeaderNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - - if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) { - continue; // If standard header, move on to next one - } - - java.util.Enumeration values = request.getHeaders(name); - if (values != null && values.hasMoreElements()) { - param = name; // Grabs the name of the first non-standard header as the parameter - // value - break; - } - } - // Note: We don't URL decode header names because people don't normally do that - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02017.java b/OWASP DATASET CLEANED/BenchmarkTest02017.java deleted file mode 100644 index fd7d463ce47398f7d67ff710e8c29b240d3edc61..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02017.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02017") -public class BenchmarkTest02017 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02017"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02018.java b/OWASP DATASET CLEANED/BenchmarkTest02018.java deleted file mode 100644 index b66c6988ab23cbe134262e1dcaa9fd4f633d24d9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02018.java +++ /dev/null @@ -1,183 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02018") -public class BenchmarkTest02018 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02018"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a50268 = param; // assign - StringBuilder b50268 = new StringBuilder(a50268); // stick in stringbuilder - b50268.append(" SafeStuff"); // append some safe content - b50268.replace( - b50268.length() - "Chars".length(), - b50268.length(), - "Chars"); // replace some of the end content - java.util.HashMap map50268 = new java.util.HashMap(); - map50268.put("key50268", b50268.toString()); // put in a collection - String c50268 = (String) map50268.get("key50268"); // get it back out - String d50268 = c50268.substring(0, c50268.length() - 1); // extract most of it - String e50268 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d50268.getBytes()))); // B64 encode and decode it - String f50268 = e50268.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f50268); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02019.java b/OWASP DATASET CLEANED/BenchmarkTest02019.java deleted file mode 100644 index feef3edd28a4fbc0b75ab2777f60c4a096819df7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02019.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02019") -public class BenchmarkTest02019 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02019"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02020.java b/OWASP DATASET CLEANED/BenchmarkTest02020.java deleted file mode 100644 index 9e09cd7b37190a1aa560cd4e63bc6fdc97731933..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02020.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02020") -public class BenchmarkTest02020 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02020"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map95233 = new java.util.HashMap(); - map95233.put("keyA-95233", "a_Value"); // put some stuff in the collection - map95233.put("keyB-95233", param); // put it in a collection - map95233.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map95233.get("keyB-95233"); // get it back out - bar = (String) map95233.get("keyA-95233"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02021.java b/OWASP DATASET CLEANED/BenchmarkTest02021.java deleted file mode 100644 index 5a945c0265c419840370f45284319f7771d50614..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02021.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02021") -public class BenchmarkTest02021 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02021"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02022.java b/OWASP DATASET CLEANED/BenchmarkTest02022.java deleted file mode 100644 index 1b7491385dec0fafe5f368fcc62681ee9a615e06..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02022.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02022") -public class BenchmarkTest02022 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02022"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02023.java b/OWASP DATASET CLEANED/BenchmarkTest02023.java deleted file mode 100644 index 36a20ac1c82968e93cf575299df90279592db312..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02023.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02023") -public class BenchmarkTest02023 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02023"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02024.java b/OWASP DATASET CLEANED/BenchmarkTest02024.java deleted file mode 100644 index 5da961946022ef6dad21d0ca4e20eb2e01912175..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02024.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02024") -public class BenchmarkTest02024 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02024"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02025.java b/OWASP DATASET CLEANED/BenchmarkTest02025.java deleted file mode 100644 index 1110a48f83a1d341a0d763c4804998d6d41398ce..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02025.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02025") -public class BenchmarkTest02025 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02025"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02026.java b/OWASP DATASET CLEANED/BenchmarkTest02026.java deleted file mode 100644 index ea8e44c248551f48b001efd4b4483da9e0fe2777..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02026.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02026") -public class BenchmarkTest02026 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02026"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02027.java b/OWASP DATASET CLEANED/BenchmarkTest02027.java deleted file mode 100644 index a3aafdaf5fddf5d2b364698c78347081b417ba23..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02027.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02027") -public class BenchmarkTest02027 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02027"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02028.java b/OWASP DATASET CLEANED/BenchmarkTest02028.java deleted file mode 100644 index 76b4d8489111aa8329bcc884bb6434c30107264e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02028.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02028") -public class BenchmarkTest02028 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02028"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02029.java b/OWASP DATASET CLEANED/BenchmarkTest02029.java deleted file mode 100644 index 7102992c516d8a51742a1224e1fce3cb9c809c81..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02029.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02029") -public class BenchmarkTest02029 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02029"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map96688 = new java.util.HashMap(); - map96688.put("keyA-96688", "a_Value"); // put some stuff in the collection - map96688.put("keyB-96688", param); // put it in a collection - map96688.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map96688.get("keyB-96688"); // get it back out - bar = (String) map96688.get("keyA-96688"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02030.java b/OWASP DATASET CLEANED/BenchmarkTest02030.java deleted file mode 100644 index 0afe770576ddd050f1dfa395f46faf17982ac5bc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02030.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02030") -public class BenchmarkTest02030 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02030"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a60868 = param; // assign - StringBuilder b60868 = new StringBuilder(a60868); // stick in stringbuilder - b60868.append(" SafeStuff"); // append some safe content - b60868.replace( - b60868.length() - "Chars".length(), - b60868.length(), - "Chars"); // replace some of the end content - java.util.HashMap map60868 = new java.util.HashMap(); - map60868.put("key60868", b60868.toString()); // put in a collection - String c60868 = (String) map60868.get("key60868"); // get it back out - String d60868 = c60868.substring(0, c60868.length() - 1); // extract most of it - String e60868 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d60868.getBytes()))); // B64 encode and decode it - String f60868 = e60868.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g60868 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g60868); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02031.java b/OWASP DATASET CLEANED/BenchmarkTest02031.java deleted file mode 100644 index ec32bf9adc598f7f680fd7f36f6c261f0ba62184..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02031.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02031") -public class BenchmarkTest02031 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02031"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02032.java b/OWASP DATASET CLEANED/BenchmarkTest02032.java deleted file mode 100644 index 50d0c07a14621064156d5ee62998862345861b18..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02032.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02032") -public class BenchmarkTest02032 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02032"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02033.java b/OWASP DATASET CLEANED/BenchmarkTest02033.java deleted file mode 100644 index 50b7b2824b8b56a1cd8b8be6180b047627221efe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02033.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02033") -public class BenchmarkTest02033 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02033"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02034.java b/OWASP DATASET CLEANED/BenchmarkTest02034.java deleted file mode 100644 index 5b369077dd03c33cca0306843e3aa92b526fe271..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02034.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02034") -public class BenchmarkTest02034 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02034"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02035.java b/OWASP DATASET CLEANED/BenchmarkTest02035.java deleted file mode 100644 index 2c8c5fd3416a752968d1d45055b31ebb0bd7e235..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02035.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02035") -public class BenchmarkTest02035 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02035"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02036.java b/OWASP DATASET CLEANED/BenchmarkTest02036.java deleted file mode 100644 index 5e33aaf50208d44ebb78332d862149d08b396d49..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02036.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02036") -public class BenchmarkTest02036 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02036"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02037.java b/OWASP DATASET CLEANED/BenchmarkTest02037.java deleted file mode 100644 index 3c00fbeb7e823bc133b5c4348b73eae338ad2c19..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02037.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02037") -public class BenchmarkTest02037 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02037"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02038.java b/OWASP DATASET CLEANED/BenchmarkTest02038.java deleted file mode 100644 index 052bf2d6054442d6b56f0785e72f28a0bf5da082..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02038.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02038") -public class BenchmarkTest02038 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02038"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02039.java b/OWASP DATASET CLEANED/BenchmarkTest02039.java deleted file mode 100644 index f30c4842e8ee5c13462f593a035923ecb3211911..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02039.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02039") -public class BenchmarkTest02039 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02039"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02040.java b/OWASP DATASET CLEANED/BenchmarkTest02040.java deleted file mode 100644 index 2b142b424598156aa39442872b8cbf113ee233aa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02040.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02040") -public class BenchmarkTest02040 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02040"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02041.java b/OWASP DATASET CLEANED/BenchmarkTest02041.java deleted file mode 100644 index 090fbfabc9619696a26ac3a2a3d61d792aa8e50f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02041.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02041") -public class BenchmarkTest02041 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02041"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02042.java b/OWASP DATASET CLEANED/BenchmarkTest02042.java deleted file mode 100644 index a3fcb28620668afdee12f1b0a586a25f9e075a35..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02042.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02042") -public class BenchmarkTest02042 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02042"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02043.java b/OWASP DATASET CLEANED/BenchmarkTest02043.java deleted file mode 100644 index 041f71d06ffc752a44272d8af8909659e48b7c8c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02043.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02043") -public class BenchmarkTest02043 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02043"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map52182 = new java.util.HashMap(); - map52182.put("keyA-52182", "a_Value"); // put some stuff in the collection - map52182.put("keyB-52182", param); // put it in a collection - map52182.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map52182.get("keyB-52182"); // get it back out - bar = (String) map52182.get("keyA-52182"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02044.java b/OWASP DATASET CLEANED/BenchmarkTest02044.java deleted file mode 100644 index 1837aa45e3f9e0e7121b207d3487bf0db7e03a26..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02044.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02044") -public class BenchmarkTest02044 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02044"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz15026 = new StringBuilder(param); - String bar = sbxyz15026.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02045.java b/OWASP DATASET CLEANED/BenchmarkTest02045.java deleted file mode 100644 index 4d6a5e7bc7d2182bad13782d5e168e67bd9ecac4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02045.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02045") -public class BenchmarkTest02045 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02046.java b/OWASP DATASET CLEANED/BenchmarkTest02046.java deleted file mode 100644 index 69e7203fe4f9bcc10fa182c17517490009de1197..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02046.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02046") -public class BenchmarkTest02046 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map81510 = new java.util.HashMap(); - map81510.put("keyA-81510", "a-Value"); // put some stuff in the collection - map81510.put("keyB-81510", param); // put it in a collection - map81510.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map81510.get("keyB-81510"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02047.java b/OWASP DATASET CLEANED/BenchmarkTest02047.java deleted file mode 100644 index 9b57ae1c385feab65e4caeef30d8bb6fcbb79c3b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02047.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02047") -public class BenchmarkTest02047 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02048.java b/OWASP DATASET CLEANED/BenchmarkTest02048.java deleted file mode 100644 index 00bc78279c091ceec37c6bf48180ca33a4c8d264..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02048.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02048") -public class BenchmarkTest02048 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a96053 = param; // assign - StringBuilder b96053 = new StringBuilder(a96053); // stick in stringbuilder - b96053.append(" SafeStuff"); // append some safe content - b96053.replace( - b96053.length() - "Chars".length(), - b96053.length(), - "Chars"); // replace some of the end content - java.util.HashMap map96053 = new java.util.HashMap(); - map96053.put("key96053", b96053.toString()); // put in a collection - String c96053 = (String) map96053.get("key96053"); // get it back out - String d96053 = c96053.substring(0, c96053.length() - 1); // extract most of it - String e96053 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d96053.getBytes()))); // B64 encode and decode it - String f96053 = e96053.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g96053 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g96053); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02049.java b/OWASP DATASET CLEANED/BenchmarkTest02049.java deleted file mode 100644 index 44e88c2297ca4b6c32cc6b241f70f0318abdf603..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02049.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02049") -public class BenchmarkTest02049 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02050.java b/OWASP DATASET CLEANED/BenchmarkTest02050.java deleted file mode 100644 index a03ae1457fe62ebe155eb4c96963c8f01a7e5705..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02050.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02050") -public class BenchmarkTest02050 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02051.java b/OWASP DATASET CLEANED/BenchmarkTest02051.java deleted file mode 100644 index ce59c69fb8a075302d2c3e89023d2bd47b0268e8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02051.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02051") -public class BenchmarkTest02051 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02052.java b/OWASP DATASET CLEANED/BenchmarkTest02052.java deleted file mode 100644 index 7bb46dd3f0ff0b70dc53c7a1b118c8f103a3242a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02052.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02052") -public class BenchmarkTest02052 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map20081 = new java.util.HashMap(); - map20081.put("keyA-20081", "a_Value"); // put some stuff in the collection - map20081.put("keyB-20081", param); // put it in a collection - map20081.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map20081.get("keyB-20081"); // get it back out - bar = (String) map20081.get("keyA-20081"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02053.java b/OWASP DATASET CLEANED/BenchmarkTest02053.java deleted file mode 100644 index a8e339f5f2511fd39bd4f519500d5fd8aa3c54fd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02053.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02053") -public class BenchmarkTest02053 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02054.java b/OWASP DATASET CLEANED/BenchmarkTest02054.java deleted file mode 100644 index 6576dc87c4d982be749c0c5f7bb7a2f8a1acd69c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02054.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02054") -public class BenchmarkTest02054 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02055.java b/OWASP DATASET CLEANED/BenchmarkTest02055.java deleted file mode 100644 index d563e244c467f9d914d23da8c7218a5e50209016..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02055.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02055") -public class BenchmarkTest02055 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02056.java b/OWASP DATASET CLEANED/BenchmarkTest02056.java deleted file mode 100644 index 1ab758ad361761360b3074af55dfaad374539214..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02056.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02056") -public class BenchmarkTest02056 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map88820 = new java.util.HashMap(); - map88820.put("keyA-88820", "a-Value"); // put some stuff in the collection - map88820.put("keyB-88820", param); // put it in a collection - map88820.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map88820.get("keyB-88820"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02057.java b/OWASP DATASET CLEANED/BenchmarkTest02057.java deleted file mode 100644 index 58db78e1cb9f48889dc57d97a2ef10f653e6e4d2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02057.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02057") -public class BenchmarkTest02057 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("Referer"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02058.java b/OWASP DATASET CLEANED/BenchmarkTest02058.java deleted file mode 100644 index 81169ca12f51a5e1adcc93088508185de26a0a7e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02058.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02058") -public class BenchmarkTest02058 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02058"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02059.java b/OWASP DATASET CLEANED/BenchmarkTest02059.java deleted file mode 100644 index 696bac4cbe1093c9d595999b699f1c28b79ab711..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02059.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02059") -public class BenchmarkTest02059 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02059"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map36421 = new java.util.HashMap(); - map36421.put("keyA-36421", "a-Value"); // put some stuff in the collection - map36421.put("keyB-36421", param); // put it in a collection - map36421.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map36421.get("keyB-36421"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02060.java b/OWASP DATASET CLEANED/BenchmarkTest02060.java deleted file mode 100644 index e567eae20c4393fef16d27b3fba30a1c6a63ee59..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02060.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02060") -public class BenchmarkTest02060 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02060"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02061.java b/OWASP DATASET CLEANED/BenchmarkTest02061.java deleted file mode 100644 index 55195bd15b6e8d25ae9996030d6320664c3d50d1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02061.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02061") -public class BenchmarkTest02061 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02061"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02062.java b/OWASP DATASET CLEANED/BenchmarkTest02062.java deleted file mode 100644 index 67aa47d36d8bab23ee6ec125524f54cbf3c84b43..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02062.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02062") -public class BenchmarkTest02062 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02062"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a60435 = param; // assign - StringBuilder b60435 = new StringBuilder(a60435); // stick in stringbuilder - b60435.append(" SafeStuff"); // append some safe content - b60435.replace( - b60435.length() - "Chars".length(), - b60435.length(), - "Chars"); // replace some of the end content - java.util.HashMap map60435 = new java.util.HashMap(); - map60435.put("key60435", b60435.toString()); // put in a collection - String c60435 = (String) map60435.get("key60435"); // get it back out - String d60435 = c60435.substring(0, c60435.length() - 1); // extract most of it - String e60435 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d60435.getBytes()))); // B64 encode and decode it - String f60435 = e60435.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g60435 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g60435); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02063.java b/OWASP DATASET CLEANED/BenchmarkTest02063.java deleted file mode 100644 index 46788324f03812c2176c43f74cc13fd0763865fd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02063.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02063") -public class BenchmarkTest02063 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02063"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02064.java b/OWASP DATASET CLEANED/BenchmarkTest02064.java deleted file mode 100644 index 9e0ea7d5fbc8003482c825cc2720ba3e427891b7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02064.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02064") -public class BenchmarkTest02064 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02064"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map96496 = new java.util.HashMap(); - map96496.put("keyA-96496", "a_Value"); // put some stuff in the collection - map96496.put("keyB-96496", param); // put it in a collection - map96496.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map96496.get("keyB-96496"); // get it back out - bar = (String) map96496.get("keyA-96496"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02065.java b/OWASP DATASET CLEANED/BenchmarkTest02065.java deleted file mode 100644 index cfbd19a660efd1e1756ddef1c0f5fb1e19234924..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02065.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02065") -public class BenchmarkTest02065 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02065"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02066.java b/OWASP DATASET CLEANED/BenchmarkTest02066.java deleted file mode 100644 index 6d8b1521172bbc052a11e57c8e62b33bc06b6642..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02066.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02066") -public class BenchmarkTest02066 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02066"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02067.java b/OWASP DATASET CLEANED/BenchmarkTest02067.java deleted file mode 100644 index a72d1eb562ea3d39a77aedd6437570020aa18382..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02067.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02067") -public class BenchmarkTest02067 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02067"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02068.java b/OWASP DATASET CLEANED/BenchmarkTest02068.java deleted file mode 100644 index 3316ddac8cf33078afe7dc0aede1a4405b4b721f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02068.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02068") -public class BenchmarkTest02068 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02068"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02069.java b/OWASP DATASET CLEANED/BenchmarkTest02069.java deleted file mode 100644 index 8a03e70ab3358cb3271c03fb392559dc2316bcc2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02069.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02069") -public class BenchmarkTest02069 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02069"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02070.java b/OWASP DATASET CLEANED/BenchmarkTest02070.java deleted file mode 100644 index 94005f784404103d5c991904ec2af455ea997358..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02070.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02070") -public class BenchmarkTest02070 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02070"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02071.java b/OWASP DATASET CLEANED/BenchmarkTest02071.java deleted file mode 100644 index 0b68acc2c79bb9cd23ec04ff12cc04337927d05f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02071.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02071") -public class BenchmarkTest02071 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02071"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map68280 = new java.util.HashMap(); - map68280.put("keyA-68280", "a-Value"); // put some stuff in the collection - map68280.put("keyB-68280", param); // put it in a collection - map68280.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map68280.get("keyB-68280"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02072.java b/OWASP DATASET CLEANED/BenchmarkTest02072.java deleted file mode 100644 index 6d9605901fea32715324823929ccb07be541b577..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02072.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02072") -public class BenchmarkTest02072 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02072"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02073.java b/OWASP DATASET CLEANED/BenchmarkTest02073.java deleted file mode 100644 index 297b6e3b87579a358c92945849bec3832aa1f4a9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02073.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02073") -public class BenchmarkTest02073 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02073"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02074.java b/OWASP DATASET CLEANED/BenchmarkTest02074.java deleted file mode 100644 index e2fe5a3e0dd00ae71aeec50816909f9157b4e92c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02074.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02074") -public class BenchmarkTest02074 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02074"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz8662 = new StringBuilder(param); - String bar = sbxyz8662.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02075.java b/OWASP DATASET CLEANED/BenchmarkTest02075.java deleted file mode 100644 index c46658af8c4fc905f4494e3a51ebfcccd844d24e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02075.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02075") -public class BenchmarkTest02075 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02075"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02076.java b/OWASP DATASET CLEANED/BenchmarkTest02076.java deleted file mode 100644 index ab90fd7698b1a2a3e1ea5b035623b44a899ce09f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02076.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02076") -public class BenchmarkTest02076 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02076"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map15760 = new java.util.HashMap(); - map15760.put("keyA-15760", "a-Value"); // put some stuff in the collection - map15760.put("keyB-15760", param); // put it in a collection - map15760.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map15760.get("keyB-15760"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02077.java b/OWASP DATASET CLEANED/BenchmarkTest02077.java deleted file mode 100644 index 6ad0a107ac482bb2fb594b8b78a3a79e9da93f1d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02077.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02077") -public class BenchmarkTest02077 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02077"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a78258 = param; // assign - StringBuilder b78258 = new StringBuilder(a78258); // stick in stringbuilder - b78258.append(" SafeStuff"); // append some safe content - b78258.replace( - b78258.length() - "Chars".length(), - b78258.length(), - "Chars"); // replace some of the end content - java.util.HashMap map78258 = new java.util.HashMap(); - map78258.put("key78258", b78258.toString()); // put in a collection - String c78258 = (String) map78258.get("key78258"); // get it back out - String d78258 = c78258.substring(0, c78258.length() - 1); // extract most of it - String e78258 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d78258.getBytes()))); // B64 encode and decode it - String f78258 = e78258.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g78258 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g78258); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02078.java b/OWASP DATASET CLEANED/BenchmarkTest02078.java deleted file mode 100644 index ba0a376ba8b50fe3afd71b20e4fc57ac35acecab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02078.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02078") -public class BenchmarkTest02078 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02078"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02079.java b/OWASP DATASET CLEANED/BenchmarkTest02079.java deleted file mode 100644 index 28f795914b33f2885e367087b210c5ad2744f5c6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02079.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02079") -public class BenchmarkTest02079 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02079"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02080.java b/OWASP DATASET CLEANED/BenchmarkTest02080.java deleted file mode 100644 index 55738d0768b8cabb5bc27d88427f8da65c16b93a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02080.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02080") -public class BenchmarkTest02080 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02080"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02081.java b/OWASP DATASET CLEANED/BenchmarkTest02081.java deleted file mode 100644 index 827b9ef9aefe00036f7087539a1778da732174d5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02081.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02081") -public class BenchmarkTest02081 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02081"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a44156 = param; // assign - StringBuilder b44156 = new StringBuilder(a44156); // stick in stringbuilder - b44156.append(" SafeStuff"); // append some safe content - b44156.replace( - b44156.length() - "Chars".length(), - b44156.length(), - "Chars"); // replace some of the end content - java.util.HashMap map44156 = new java.util.HashMap(); - map44156.put("key44156", b44156.toString()); // put in a collection - String c44156 = (String) map44156.get("key44156"); // get it back out - String d44156 = c44156.substring(0, c44156.length() - 1); // extract most of it - String e44156 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d44156.getBytes()))); // B64 encode and decode it - String f44156 = e44156.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f44156); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02082.java b/OWASP DATASET CLEANED/BenchmarkTest02082.java deleted file mode 100644 index a0750aad4b8bb4854a1c033d0c1ef303cde75150..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02082.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02082") -public class BenchmarkTest02082 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02082"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02083.java b/OWASP DATASET CLEANED/BenchmarkTest02083.java deleted file mode 100644 index 12783e265aa228930ede8a8693e1c7e7a3ce5bf1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02083.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02083") -public class BenchmarkTest02083 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02083"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02084.java b/OWASP DATASET CLEANED/BenchmarkTest02084.java deleted file mode 100644 index 9f810fe2a3d05517870ee1314ff9490834e13bba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02084.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02084") -public class BenchmarkTest02084 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02084"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02085.java b/OWASP DATASET CLEANED/BenchmarkTest02085.java deleted file mode 100644 index bf265eb7ee1081e19c715bc9b6024d193a4cc0b8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02085.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02085") -public class BenchmarkTest02085 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02085"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02086.java b/OWASP DATASET CLEANED/BenchmarkTest02086.java deleted file mode 100644 index 9bad930644737aa0093e61835f139adea7170551..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02086.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02086") -public class BenchmarkTest02086 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02086"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02087.java b/OWASP DATASET CLEANED/BenchmarkTest02087.java deleted file mode 100644 index 41825b6aa833f7d17656c98cde212e196f0d0930..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02087.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02087") -public class BenchmarkTest02087 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02087"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02088.java b/OWASP DATASET CLEANED/BenchmarkTest02088.java deleted file mode 100644 index d7221da5d40b5f70e6c02a834ede95b74cf4c1e9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02088.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02088") -public class BenchmarkTest02088 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02088"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02089.java b/OWASP DATASET CLEANED/BenchmarkTest02089.java deleted file mode 100644 index a5867c1b738549c8e8bd4cef01e24639f19a7244..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02089.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02089") -public class BenchmarkTest02089 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02089"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02090.java b/OWASP DATASET CLEANED/BenchmarkTest02090.java deleted file mode 100644 index a79d032702d8ddd36e5702b36badb1ab41ce48dc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02090.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02090") -public class BenchmarkTest02090 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02090"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02091.java b/OWASP DATASET CLEANED/BenchmarkTest02091.java deleted file mode 100644 index 6e5814906b544336fa4d110d35d87a6dcb04425f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02091.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02091") -public class BenchmarkTest02091 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02091"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02092.java b/OWASP DATASET CLEANED/BenchmarkTest02092.java deleted file mode 100644 index 669ee4c7ee9eae7af6e1029534325f06ad3b0bdd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02092.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02092") -public class BenchmarkTest02092 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02092"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02093.java b/OWASP DATASET CLEANED/BenchmarkTest02093.java deleted file mode 100644 index 62bad61b554fec90093dac310e67d45d0dfff969..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02093.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02093") -public class BenchmarkTest02093 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02093"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02094.java b/OWASP DATASET CLEANED/BenchmarkTest02094.java deleted file mode 100644 index 1bd07a5103280209de40251b5af45f6047e1cee7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02094.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02094") -public class BenchmarkTest02094 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02094"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02095.java b/OWASP DATASET CLEANED/BenchmarkTest02095.java deleted file mode 100644 index 9e58f570310ae7a8738725a491737bf28b453702..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02095.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02095") -public class BenchmarkTest02095 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02095"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map43923 = new java.util.HashMap(); - map43923.put("keyA-43923", "a_Value"); // put some stuff in the collection - map43923.put("keyB-43923", param); // put it in a collection - map43923.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map43923.get("keyB-43923"); // get it back out - bar = (String) map43923.get("keyA-43923"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02096.java b/OWASP DATASET CLEANED/BenchmarkTest02096.java deleted file mode 100644 index 0b69ffd348c48fae28b17895aaf7a16bef142a75..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02096.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02096") -public class BenchmarkTest02096 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02096"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02097.java b/OWASP DATASET CLEANED/BenchmarkTest02097.java deleted file mode 100644 index a34bc2846d6321f43465a9af0562566a1734f55a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02097.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02097") -public class BenchmarkTest02097 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02097"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map94015 = new java.util.HashMap(); - map94015.put("keyA-94015", "a_Value"); // put some stuff in the collection - map94015.put("keyB-94015", param); // put it in a collection - map94015.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map94015.get("keyB-94015"); // get it back out - bar = (String) map94015.get("keyA-94015"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02098.java b/OWASP DATASET CLEANED/BenchmarkTest02098.java deleted file mode 100644 index 3df3672ee353ed90cc0f6a0cdc24e6c039e8150a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02098.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02098") -public class BenchmarkTest02098 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02098"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02099.java b/OWASP DATASET CLEANED/BenchmarkTest02099.java deleted file mode 100644 index c68f1bc5828ce5df2e89f8b36e1f173b60c51c6a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02099.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02099") -public class BenchmarkTest02099 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02099"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02100.java b/OWASP DATASET CLEANED/BenchmarkTest02100.java deleted file mode 100644 index 63b61d1f8af3ae002d57a8e3fbaaccbac56b5a04..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02100.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest02100") -public class BenchmarkTest02100 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - java.util.Enumeration headers = request.getHeaders("BenchmarkTest02100"); - - if (headers != null && headers.hasMoreElements()) { - param = headers.nextElement(); // just grab first element - } - - // URL Decode the header value since req.getHeaders() doesn't. Unlike req.getParameters(). - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02101.java b/OWASP DATASET CLEANED/BenchmarkTest02101.java deleted file mode 100644 index 1930744b9bd68d3b8a34e2eed57d79267a1f8115..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02101.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02101") -public class BenchmarkTest02101 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02101"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02102.java b/OWASP DATASET CLEANED/BenchmarkTest02102.java deleted file mode 100644 index 9a09a0988eac73dcda03e706bfe92b019da2aed3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02102.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02102") -public class BenchmarkTest02102 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02102"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz85369 = new StringBuilder(param); - bar = sbxyz85369.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02103.java b/OWASP DATASET CLEANED/BenchmarkTest02103.java deleted file mode 100644 index 4ab83895b03e2f6e7f7dd948a0b0078f83cfaaea..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02103.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02103") -public class BenchmarkTest02103 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02103"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02104.java b/OWASP DATASET CLEANED/BenchmarkTest02104.java deleted file mode 100644 index 63ddf9e267a3fce7849a7145c2cc4d1785cae539..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02104.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02104") -public class BenchmarkTest02104 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02104"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02105.java b/OWASP DATASET CLEANED/BenchmarkTest02105.java deleted file mode 100644 index 058b1e2c8d5a9c826568137d05b9c5a3629843d5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02105.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02105") -public class BenchmarkTest02105 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02105"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02106.java b/OWASP DATASET CLEANED/BenchmarkTest02106.java deleted file mode 100644 index e1f8a4c5862ad4c5fc79a484523a9501f018327b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02106.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02106") -public class BenchmarkTest02106 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02106"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02107.java b/OWASP DATASET CLEANED/BenchmarkTest02107.java deleted file mode 100644 index acb89d78ab3eafa015eaaa70046c3932f001af76..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02107.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02107") -public class BenchmarkTest02107 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02107"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02108.java b/OWASP DATASET CLEANED/BenchmarkTest02108.java deleted file mode 100644 index 7111fdf9d1bd83fb5218afb9cf84bc5eca430d03..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02108.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02108") -public class BenchmarkTest02108 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02108"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map44255 = new java.util.HashMap(); - map44255.put("keyA-44255", "a_Value"); // put some stuff in the collection - map44255.put("keyB-44255", param); // put it in a collection - map44255.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map44255.get("keyB-44255"); // get it back out - bar = (String) map44255.get("keyA-44255"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02109.java b/OWASP DATASET CLEANED/BenchmarkTest02109.java deleted file mode 100644 index baa9a5756414ff981bab0a49253f7088d64b7aac..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02109.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02109") -public class BenchmarkTest02109 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02109"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02110.java b/OWASP DATASET CLEANED/BenchmarkTest02110.java deleted file mode 100644 index e792992132e1ad70bdc19c23d6df63d60619f5a0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02110.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02110") -public class BenchmarkTest02110 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02110"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02111.java b/OWASP DATASET CLEANED/BenchmarkTest02111.java deleted file mode 100644 index c7e4f0bbdd3d78517961331881292bf10156bcbf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02111.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02111") -public class BenchmarkTest02111 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02111"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02112.java b/OWASP DATASET CLEANED/BenchmarkTest02112.java deleted file mode 100644 index 54382ed0a93d1f3b2bb54c2cde53ba12b575e16d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02112.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02112") -public class BenchmarkTest02112 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02112"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02113.java b/OWASP DATASET CLEANED/BenchmarkTest02113.java deleted file mode 100644 index c775f93bbacb375e246294dc47090ed557dd949e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02113.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02113") -public class BenchmarkTest02113 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02113"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02114.java b/OWASP DATASET CLEANED/BenchmarkTest02114.java deleted file mode 100644 index 42e5b583976b7d5988ad1d5f22c3acfa2b6212e8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02114.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02114") -public class BenchmarkTest02114 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02114"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02115.java b/OWASP DATASET CLEANED/BenchmarkTest02115.java deleted file mode 100644 index dbc0bc3d18fe7bf07c537d214ad9f1425374409c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02115.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02115") -public class BenchmarkTest02115 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02115"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map89109 = new java.util.HashMap(); - map89109.put("keyA-89109", "a_Value"); // put some stuff in the collection - map89109.put("keyB-89109", param); // put it in a collection - map89109.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map89109.get("keyB-89109"); // get it back out - bar = (String) map89109.get("keyA-89109"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02116.java b/OWASP DATASET CLEANED/BenchmarkTest02116.java deleted file mode 100644 index a1dc8d7ca11d8cd867984282fb7d6dbc6529529a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02116.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02116") -public class BenchmarkTest02116 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02116"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02117.java b/OWASP DATASET CLEANED/BenchmarkTest02117.java deleted file mode 100644 index 4a05c53e24856d7a26b7c459b8315146bcb95c72..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02117.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02117") -public class BenchmarkTest02117 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02117"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map12987 = new java.util.HashMap(); - map12987.put("keyA-12987", "a-Value"); // put some stuff in the collection - map12987.put("keyB-12987", param); // put it in a collection - map12987.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map12987.get("keyB-12987"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02118.java b/OWASP DATASET CLEANED/BenchmarkTest02118.java deleted file mode 100644 index 53fe8213389c4008d3f16e4118f8eece00cb95fa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02118.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02118") -public class BenchmarkTest02118 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02118"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02119.java b/OWASP DATASET CLEANED/BenchmarkTest02119.java deleted file mode 100644 index e81475361111a397a75469d08b67d11f0903d580..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02119.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02119") -public class BenchmarkTest02119 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02119"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map70096 = new java.util.HashMap(); - map70096.put("keyA-70096", "a-Value"); // put some stuff in the collection - map70096.put("keyB-70096", param); // put it in a collection - map70096.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map70096.get("keyB-70096"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02120.java b/OWASP DATASET CLEANED/BenchmarkTest02120.java deleted file mode 100644 index db5d2486359098acddc20c8a8299b93cb3c228d1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02120.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02120") -public class BenchmarkTest02120 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02120"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02121.java b/OWASP DATASET CLEANED/BenchmarkTest02121.java deleted file mode 100644 index c4a545536cc60197cb998f588aa2050fb10a40e4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02121.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02121") -public class BenchmarkTest02121 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02121"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02122.java b/OWASP DATASET CLEANED/BenchmarkTest02122.java deleted file mode 100644 index b1d3c0658f2ce3367f4187d0828faaeedd7bed13..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02122.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-03/BenchmarkTest02122") -public class BenchmarkTest02122 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02122"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02123.java b/OWASP DATASET CLEANED/BenchmarkTest02123.java deleted file mode 100644 index ca56b64dc44f24ac68d0d7eff89f4a1ab3476295..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02123.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02123") -public class BenchmarkTest02123 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02123"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02124.java b/OWASP DATASET CLEANED/BenchmarkTest02124.java deleted file mode 100644 index 42394ba69f99c5377415c341e132ded5398eda2c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02124.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02124") -public class BenchmarkTest02124 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02124"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz69250 = new StringBuilder(param); - bar = sbxyz69250.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02125.java b/OWASP DATASET CLEANED/BenchmarkTest02125.java deleted file mode 100644 index 292411b39ca52de3483f2a224452be093df122e6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02125.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02125") -public class BenchmarkTest02125 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02125"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02126.java b/OWASP DATASET CLEANED/BenchmarkTest02126.java deleted file mode 100644 index d6c2d9216e81a265751bbc91c1722718f3b68d0f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02126.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02126") -public class BenchmarkTest02126 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02126"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a64181 = param; // assign - StringBuilder b64181 = new StringBuilder(a64181); // stick in stringbuilder - b64181.append(" SafeStuff"); // append some safe content - b64181.replace( - b64181.length() - "Chars".length(), - b64181.length(), - "Chars"); // replace some of the end content - java.util.HashMap map64181 = new java.util.HashMap(); - map64181.put("key64181", b64181.toString()); // put in a collection - String c64181 = (String) map64181.get("key64181"); // get it back out - String d64181 = c64181.substring(0, c64181.length() - 1); // extract most of it - String e64181 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d64181.getBytes()))); // B64 encode and decode it - String f64181 = e64181.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f64181); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02127.java b/OWASP DATASET CLEANED/BenchmarkTest02127.java deleted file mode 100644 index 887f06f7536e4033cbdeefb9cb339f0ff15ecfd7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02127.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02127") -public class BenchmarkTest02127 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02127"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02128.java b/OWASP DATASET CLEANED/BenchmarkTest02128.java deleted file mode 100644 index b805802fd5e7161cabab44f112e67ed7801f0244..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02128.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02128") -public class BenchmarkTest02128 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02128"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02129.java b/OWASP DATASET CLEANED/BenchmarkTest02129.java deleted file mode 100644 index 0ef4919c541c11eff2e6e1ad262bcc0c2ae24820..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02129.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02129") -public class BenchmarkTest02129 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02129"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02130.java b/OWASP DATASET CLEANED/BenchmarkTest02130.java deleted file mode 100644 index 815e4acba946c090c96fa91a35cd99813f73d6cd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02130.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02130") -public class BenchmarkTest02130 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02130"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz60224 = new StringBuilder(param); - String bar = sbxyz60224.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02131.java b/OWASP DATASET CLEANED/BenchmarkTest02131.java deleted file mode 100644 index 85eacdf529f970448ff05242095fe254af699164..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02131.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02131") -public class BenchmarkTest02131 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02131"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02132.java b/OWASP DATASET CLEANED/BenchmarkTest02132.java deleted file mode 100644 index b33a9666f2e262dc062c9f765b06c53d34198cbf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02132.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02132") -public class BenchmarkTest02132 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02132"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a76744 = param; // assign - StringBuilder b76744 = new StringBuilder(a76744); // stick in stringbuilder - b76744.append(" SafeStuff"); // append some safe content - b76744.replace( - b76744.length() - "Chars".length(), - b76744.length(), - "Chars"); // replace some of the end content - java.util.HashMap map76744 = new java.util.HashMap(); - map76744.put("key76744", b76744.toString()); // put in a collection - String c76744 = (String) map76744.get("key76744"); // get it back out - String d76744 = c76744.substring(0, c76744.length() - 1); // extract most of it - String e76744 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d76744.getBytes()))); // B64 encode and decode it - String f76744 = e76744.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f76744); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02133.java b/OWASP DATASET CLEANED/BenchmarkTest02133.java deleted file mode 100644 index 525363e6fca94778e7f0408d01c7d1bc1232c528..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02133.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02133") -public class BenchmarkTest02133 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02133"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02134.java b/OWASP DATASET CLEANED/BenchmarkTest02134.java deleted file mode 100644 index 56cfa69c072d49ed7b22813d5431f4ccffa312d4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02134.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02134") -public class BenchmarkTest02134 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02134"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02135.java b/OWASP DATASET CLEANED/BenchmarkTest02135.java deleted file mode 100644 index 000c66248dd45c65b4641633d0a0b9611918ec4a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02135.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02135") -public class BenchmarkTest02135 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02135"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a95930 = param; // assign - StringBuilder b95930 = new StringBuilder(a95930); // stick in stringbuilder - b95930.append(" SafeStuff"); // append some safe content - b95930.replace( - b95930.length() - "Chars".length(), - b95930.length(), - "Chars"); // replace some of the end content - java.util.HashMap map95930 = new java.util.HashMap(); - map95930.put("key95930", b95930.toString()); // put in a collection - String c95930 = (String) map95930.get("key95930"); // get it back out - String d95930 = c95930.substring(0, c95930.length() - 1); // extract most of it - String e95930 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d95930.getBytes()))); // B64 encode and decode it - String f95930 = e95930.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g95930 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g95930); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02136.java b/OWASP DATASET CLEANED/BenchmarkTest02136.java deleted file mode 100644 index e92b64be22b885f924bb734b45865c3ab6f2104d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02136.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02136") -public class BenchmarkTest02136 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02136"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02137.java b/OWASP DATASET CLEANED/BenchmarkTest02137.java deleted file mode 100644 index d25ef2956216d7b69a532464efb077e46ed49065..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02137.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02137") -public class BenchmarkTest02137 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02137"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02138.java b/OWASP DATASET CLEANED/BenchmarkTest02138.java deleted file mode 100644 index 50da3f1f59f5ca1687e52fd3d0c950b06580f64c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02138.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02138") -public class BenchmarkTest02138 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02138"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02139.java b/OWASP DATASET CLEANED/BenchmarkTest02139.java deleted file mode 100644 index b13525189d475102e549a82a8c3b6c2bf8a4aa61..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02139.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02139") -public class BenchmarkTest02139 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02139"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02140.java b/OWASP DATASET CLEANED/BenchmarkTest02140.java deleted file mode 100644 index 58c2eaa04776103a7c93d7086cd597259b336b95..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02140.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02140") -public class BenchmarkTest02140 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02140"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02141.java b/OWASP DATASET CLEANED/BenchmarkTest02141.java deleted file mode 100644 index 6bf79db86749a0d23c28e5bf3d71d64d59cbe820..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02141.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02141") -public class BenchmarkTest02141 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02141"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02142.java b/OWASP DATASET CLEANED/BenchmarkTest02142.java deleted file mode 100644 index 671b55445595f98d092d99bf409a01e8c735181c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02142.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02142") -public class BenchmarkTest02142 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02142"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02143.java b/OWASP DATASET CLEANED/BenchmarkTest02143.java deleted file mode 100644 index daed648eb85c92c6984a6b9dcf5bfa303b141b4c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02143.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02143") -public class BenchmarkTest02143 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02143"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map44285 = new java.util.HashMap(); - map44285.put("keyA-44285", "a_Value"); // put some stuff in the collection - map44285.put("keyB-44285", param); // put it in a collection - map44285.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map44285.get("keyB-44285"); // get it back out - bar = (String) map44285.get("keyA-44285"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02144.java b/OWASP DATASET CLEANED/BenchmarkTest02144.java deleted file mode 100644 index 5db8352bb96d5800270ae5d3f986b12812bdf5bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02144.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02144") -public class BenchmarkTest02144 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02144"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02145.java b/OWASP DATASET CLEANED/BenchmarkTest02145.java deleted file mode 100644 index d83254d0536adbf56b34771e541c3aa424f96f05..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02145.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02145") -public class BenchmarkTest02145 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02145"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a32743 = param; // assign - StringBuilder b32743 = new StringBuilder(a32743); // stick in stringbuilder - b32743.append(" SafeStuff"); // append some safe content - b32743.replace( - b32743.length() - "Chars".length(), - b32743.length(), - "Chars"); // replace some of the end content - java.util.HashMap map32743 = new java.util.HashMap(); - map32743.put("key32743", b32743.toString()); // put in a collection - String c32743 = (String) map32743.get("key32743"); // get it back out - String d32743 = c32743.substring(0, c32743.length() - 1); // extract most of it - String e32743 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d32743.getBytes()))); // B64 encode and decode it - String f32743 = e32743.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f32743); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02146.java b/OWASP DATASET CLEANED/BenchmarkTest02146.java deleted file mode 100644 index faaee753c9bd29b146567df0c56ec06de4115834..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02146.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02146") -public class BenchmarkTest02146 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02146"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02147.java b/OWASP DATASET CLEANED/BenchmarkTest02147.java deleted file mode 100644 index e5b87e810af4e4b277d07ccf3997809263510199..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02147.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02147") -public class BenchmarkTest02147 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02147"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02148.java b/OWASP DATASET CLEANED/BenchmarkTest02148.java deleted file mode 100644 index d9efbca6ee56b8d1083ea64585d6e6e6d114c2f2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02148.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02148") -public class BenchmarkTest02148 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02148"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a17988 = param; // assign - StringBuilder b17988 = new StringBuilder(a17988); // stick in stringbuilder - b17988.append(" SafeStuff"); // append some safe content - b17988.replace( - b17988.length() - "Chars".length(), - b17988.length(), - "Chars"); // replace some of the end content - java.util.HashMap map17988 = new java.util.HashMap(); - map17988.put("key17988", b17988.toString()); // put in a collection - String c17988 = (String) map17988.get("key17988"); // get it back out - String d17988 = c17988.substring(0, c17988.length() - 1); // extract most of it - String e17988 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d17988.getBytes()))); // B64 encode and decode it - String f17988 = e17988.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g17988 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g17988); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02149.java b/OWASP DATASET CLEANED/BenchmarkTest02149.java deleted file mode 100644 index 77f899b2573bc0f7765724d2e8308d2a540dee77..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02149.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02149") -public class BenchmarkTest02149 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02149"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02150.java b/OWASP DATASET CLEANED/BenchmarkTest02150.java deleted file mode 100644 index c0b1e17f6f2de75b034ec0f84820472522ed55d5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02150.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02150") -public class BenchmarkTest02150 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02150"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02151.java b/OWASP DATASET CLEANED/BenchmarkTest02151.java deleted file mode 100644 index 45e621ee925e1890c63935c118f14e4f49073766..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02151.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02151") -public class BenchmarkTest02151 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02151"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02152.java b/OWASP DATASET CLEANED/BenchmarkTest02152.java deleted file mode 100644 index e87508dbf9052539ec0b277c3a52c95228f68c41..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02152.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02152") -public class BenchmarkTest02152 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02152"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02153.java b/OWASP DATASET CLEANED/BenchmarkTest02153.java deleted file mode 100644 index 54c7827c4abb1bbb2cb8ebca96a29d9dd3201d6a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02153.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02153") -public class BenchmarkTest02153 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02153"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a82592 = param; // assign - StringBuilder b82592 = new StringBuilder(a82592); // stick in stringbuilder - b82592.append(" SafeStuff"); // append some safe content - b82592.replace( - b82592.length() - "Chars".length(), - b82592.length(), - "Chars"); // replace some of the end content - java.util.HashMap map82592 = new java.util.HashMap(); - map82592.put("key82592", b82592.toString()); // put in a collection - String c82592 = (String) map82592.get("key82592"); // get it back out - String d82592 = c82592.substring(0, c82592.length() - 1); // extract most of it - String e82592 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d82592.getBytes()))); // B64 encode and decode it - String f82592 = e82592.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g82592 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g82592); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02154.java b/OWASP DATASET CLEANED/BenchmarkTest02154.java deleted file mode 100644 index b989c97c0320fc824b5809f589ff70738037e8a5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02154.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02154") -public class BenchmarkTest02154 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02154"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02155.java b/OWASP DATASET CLEANED/BenchmarkTest02155.java deleted file mode 100644 index 8dea5d4ceb277cae129bc37bc0f09a144fc3d4bc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02155.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02155") -public class BenchmarkTest02155 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02155"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02156.java b/OWASP DATASET CLEANED/BenchmarkTest02156.java deleted file mode 100644 index 5e1c14db534a68e816b8c604fc52f222e98f491b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02156.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02156") -public class BenchmarkTest02156 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02156"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02157.java b/OWASP DATASET CLEANED/BenchmarkTest02157.java deleted file mode 100644 index 776e92431aefb66f02b619442bb3f18b1d5bb0e6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02157.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02157") -public class BenchmarkTest02157 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02157"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02158.java b/OWASP DATASET CLEANED/BenchmarkTest02158.java deleted file mode 100644 index 230d185a070485849268bcb5a1ce84cbeb04195b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02158.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-04/BenchmarkTest02158") -public class BenchmarkTest02158 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02158"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02159.java b/OWASP DATASET CLEANED/BenchmarkTest02159.java deleted file mode 100644 index b005fa93436a8a94164059749d29fbf729a6a47f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02159.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02159") -public class BenchmarkTest02159 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02159"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a66015 = param; // assign - StringBuilder b66015 = new StringBuilder(a66015); // stick in stringbuilder - b66015.append(" SafeStuff"); // append some safe content - b66015.replace( - b66015.length() - "Chars".length(), - b66015.length(), - "Chars"); // replace some of the end content - java.util.HashMap map66015 = new java.util.HashMap(); - map66015.put("key66015", b66015.toString()); // put in a collection - String c66015 = (String) map66015.get("key66015"); // get it back out - String d66015 = c66015.substring(0, c66015.length() - 1); // extract most of it - String e66015 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d66015.getBytes()))); // B64 encode and decode it - String f66015 = e66015.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f66015); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02160.java b/OWASP DATASET CLEANED/BenchmarkTest02160.java deleted file mode 100644 index c221e06bb0306cfcae672ca3e07dc4e89005ca65..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02160.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02160") -public class BenchmarkTest02160 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02160"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map25458 = new java.util.HashMap(); - map25458.put("keyA-25458", "a_Value"); // put some stuff in the collection - map25458.put("keyB-25458", param); // put it in a collection - map25458.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map25458.get("keyB-25458"); // get it back out - bar = (String) map25458.get("keyA-25458"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02161.java b/OWASP DATASET CLEANED/BenchmarkTest02161.java deleted file mode 100644 index 29d2b21dcfbf67cddfe152fccbd9e33ea8820435..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02161.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02161") -public class BenchmarkTest02161 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02161"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02162.java b/OWASP DATASET CLEANED/BenchmarkTest02162.java deleted file mode 100644 index c0789684a0977931d98f0cb93664950f6ac014da..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02162.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02162") -public class BenchmarkTest02162 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02162"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02163.java b/OWASP DATASET CLEANED/BenchmarkTest02163.java deleted file mode 100644 index 9203925d5d91e34c33bb24d35d37a6b5f3ba1ded..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02163.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02163") -public class BenchmarkTest02163 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02163"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02164.java b/OWASP DATASET CLEANED/BenchmarkTest02164.java deleted file mode 100644 index 151beb6a0903cc2454bf45da4245715e0646c4f8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02164.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02164") -public class BenchmarkTest02164 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02164"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02165.java b/OWASP DATASET CLEANED/BenchmarkTest02165.java deleted file mode 100644 index 92adf8ed4aa5d59c104a32f187313bb68cbbd0f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02165.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02165") -public class BenchmarkTest02165 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02165"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02166.java b/OWASP DATASET CLEANED/BenchmarkTest02166.java deleted file mode 100644 index 6ed257521ee75054baa08a68f2e2243af4438e7f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02166.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02166") -public class BenchmarkTest02166 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02166"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02167.java b/OWASP DATASET CLEANED/BenchmarkTest02167.java deleted file mode 100644 index b674146f9cab88d59bddc573aac162b798ff3dbd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02167.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02167") -public class BenchmarkTest02167 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02167"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02168.java b/OWASP DATASET CLEANED/BenchmarkTest02168.java deleted file mode 100644 index 056ae5012f51e2a92d78dfe3b00e8be54ca3ff80..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02168.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02168") -public class BenchmarkTest02168 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02168"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02169.java b/OWASP DATASET CLEANED/BenchmarkTest02169.java deleted file mode 100644 index 0e7ff768c71229e18a92411ff8826eddcd4ec614..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02169.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02169") -public class BenchmarkTest02169 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02169"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02170.java b/OWASP DATASET CLEANED/BenchmarkTest02170.java deleted file mode 100644 index 04587551cdc745bc6fecb3dffb0c66bb2dac8b69..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02170.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02170") -public class BenchmarkTest02170 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02170"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02171.java b/OWASP DATASET CLEANED/BenchmarkTest02171.java deleted file mode 100644 index 5456ea5f8d27e111af1cda578e0920317bb7d492..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02171.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02171") -public class BenchmarkTest02171 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02171"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02172.java b/OWASP DATASET CLEANED/BenchmarkTest02172.java deleted file mode 100644 index aeeee038af17ff315ec5c5c90a4ea49238302864..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02172.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02172") -public class BenchmarkTest02172 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02172"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02173.java b/OWASP DATASET CLEANED/BenchmarkTest02173.java deleted file mode 100644 index e26a2f320a677fcff7a930e885fb1c5a90845baa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02173.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02173") -public class BenchmarkTest02173 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02173"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02174.java b/OWASP DATASET CLEANED/BenchmarkTest02174.java deleted file mode 100644 index 7f03611b7bd1a93825933c94e30a5d4c5e3f09e6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02174.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02174") -public class BenchmarkTest02174 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02174"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02175.java b/OWASP DATASET CLEANED/BenchmarkTest02175.java deleted file mode 100644 index 4a8edc6a7672e80b1448192d910a69f4351eb26a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02175.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02175") -public class BenchmarkTest02175 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02175"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02176.java b/OWASP DATASET CLEANED/BenchmarkTest02176.java deleted file mode 100644 index 98d9985b1edd5cb503ea5c37d298a15cb5d3c0b4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02176.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02176") -public class BenchmarkTest02176 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02176"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02177.java b/OWASP DATASET CLEANED/BenchmarkTest02177.java deleted file mode 100644 index 5a3a0bef1031a58bfe571c13d6d5f235d4d94d7f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02177.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02177") -public class BenchmarkTest02177 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02177"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02178.java b/OWASP DATASET CLEANED/BenchmarkTest02178.java deleted file mode 100644 index 9fb366b9fbb87f672800b6482fd3a9c4513282cb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02178.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02178") -public class BenchmarkTest02178 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02178"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map38026 = new java.util.HashMap(); - map38026.put("keyA-38026", "a-Value"); // put some stuff in the collection - map38026.put("keyB-38026", param); // put it in a collection - map38026.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map38026.get("keyB-38026"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02179.java b/OWASP DATASET CLEANED/BenchmarkTest02179.java deleted file mode 100644 index 7c64a0ddb2b055ab991f2fbe5520310d2d9d6964..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02179.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02179") -public class BenchmarkTest02179 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02179"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02180.java b/OWASP DATASET CLEANED/BenchmarkTest02180.java deleted file mode 100644 index 9f3ca18c83c2942929e5eb15c156652dbc0efd82..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02180.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02180") -public class BenchmarkTest02180 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02180"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map32515 = new java.util.HashMap(); - map32515.put("keyA-32515", "a_Value"); // put some stuff in the collection - map32515.put("keyB-32515", param); // put it in a collection - map32515.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map32515.get("keyB-32515"); // get it back out - bar = (String) map32515.get("keyA-32515"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02181.java b/OWASP DATASET CLEANED/BenchmarkTest02181.java deleted file mode 100644 index 15b365ce9e8c9ffcfdfda888fc22e1505722c482..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02181.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02181") -public class BenchmarkTest02181 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02181"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02182.java b/OWASP DATASET CLEANED/BenchmarkTest02182.java deleted file mode 100644 index f2e08c96a027dcc3833a9f1dff8a1fc70e89a823..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02182.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02182") -public class BenchmarkTest02182 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02182"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02183.java b/OWASP DATASET CLEANED/BenchmarkTest02183.java deleted file mode 100644 index 4d2a03d9513f9a8398272716186af82d02bcbea4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02183.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02183") -public class BenchmarkTest02183 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02183"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a90580 = param; // assign - StringBuilder b90580 = new StringBuilder(a90580); // stick in stringbuilder - b90580.append(" SafeStuff"); // append some safe content - b90580.replace( - b90580.length() - "Chars".length(), - b90580.length(), - "Chars"); // replace some of the end content - java.util.HashMap map90580 = new java.util.HashMap(); - map90580.put("key90580", b90580.toString()); // put in a collection - String c90580 = (String) map90580.get("key90580"); // get it back out - String d90580 = c90580.substring(0, c90580.length() - 1); // extract most of it - String e90580 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d90580.getBytes()))); // B64 encode and decode it - String f90580 = e90580.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g90580 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g90580); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02184.java b/OWASP DATASET CLEANED/BenchmarkTest02184.java deleted file mode 100644 index 440e5401741a645ae5481aa005a3e72bffc0b21a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02184.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02184") -public class BenchmarkTest02184 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02184"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02185.java b/OWASP DATASET CLEANED/BenchmarkTest02185.java deleted file mode 100644 index 4deedfcbebba0c3fe7ff6ea7ef69aa772929edc8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02185.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02185") -public class BenchmarkTest02185 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02185"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02186.java b/OWASP DATASET CLEANED/BenchmarkTest02186.java deleted file mode 100644 index 2585b309c068f75b2454d0b6fbd27ef9532c73cd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02186.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02186") -public class BenchmarkTest02186 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02186"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02187.java b/OWASP DATASET CLEANED/BenchmarkTest02187.java deleted file mode 100644 index 6333aeed5f16322b1eea56f8af2151f854a469e0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02187.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02187") -public class BenchmarkTest02187 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02187"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02188.java b/OWASP DATASET CLEANED/BenchmarkTest02188.java deleted file mode 100644 index ff72471884d69f8fb4374e5b8e191740cadda359..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02188.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02188") -public class BenchmarkTest02188 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02188"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a16667 = param; // assign - StringBuilder b16667 = new StringBuilder(a16667); // stick in stringbuilder - b16667.append(" SafeStuff"); // append some safe content - b16667.replace( - b16667.length() - "Chars".length(), - b16667.length(), - "Chars"); // replace some of the end content - java.util.HashMap map16667 = new java.util.HashMap(); - map16667.put("key16667", b16667.toString()); // put in a collection - String c16667 = (String) map16667.get("key16667"); // get it back out - String d16667 = c16667.substring(0, c16667.length() - 1); // extract most of it - String e16667 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d16667.getBytes()))); // B64 encode and decode it - String f16667 = e16667.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g16667 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g16667); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02189.java b/OWASP DATASET CLEANED/BenchmarkTest02189.java deleted file mode 100644 index af05e26635caf0af99543dbb1a148920b0dacdc1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02189.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest02189") -public class BenchmarkTest02189 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = request.getParameter("BenchmarkTest02189"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02190.java b/OWASP DATASET CLEANED/BenchmarkTest02190.java deleted file mode 100644 index 16c3374b0899d1eaae8aa65b0148903d3e398af5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02190.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02190") -public class BenchmarkTest02190 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02190"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02191.java b/OWASP DATASET CLEANED/BenchmarkTest02191.java deleted file mode 100644 index 33a97738839640db2c44f5f90e9d20eb89c08590..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02191.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02191") -public class BenchmarkTest02191 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02191"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02192.java b/OWASP DATASET CLEANED/BenchmarkTest02192.java deleted file mode 100644 index 8a5b1e5beba1d5870c0991b4a0f13a5b347a8a2b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02192.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02192") -public class BenchmarkTest02192 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02192"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02193.java b/OWASP DATASET CLEANED/BenchmarkTest02193.java deleted file mode 100644 index 72a5551228c6e0fed02b1eb9328d753e40d06e75..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02193.java +++ /dev/null @@ -1,183 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02193") -public class BenchmarkTest02193 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02193"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02194.java b/OWASP DATASET CLEANED/BenchmarkTest02194.java deleted file mode 100644 index 9ddca94c22b4c66c1f623696a4640dc7cd1bf11b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02194.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02194") -public class BenchmarkTest02194 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02194"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02195.java b/OWASP DATASET CLEANED/BenchmarkTest02195.java deleted file mode 100644 index 01595fc13c52583b52f2197b9ded2045910ad1f8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02195.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02195") -public class BenchmarkTest02195 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02195"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02196.java b/OWASP DATASET CLEANED/BenchmarkTest02196.java deleted file mode 100644 index de20630555bebd2cafb44db591ccd4ec0dc71637..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02196.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02196") -public class BenchmarkTest02196 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02196"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02197.java b/OWASP DATASET CLEANED/BenchmarkTest02197.java deleted file mode 100644 index 8906b740d725b1e81b688ad80ee3c858b987da23..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02197.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02197") -public class BenchmarkTest02197 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02197"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map35951 = new java.util.HashMap(); - map35951.put("keyA-35951", "a-Value"); // put some stuff in the collection - map35951.put("keyB-35951", param); // put it in a collection - map35951.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map35951.get("keyB-35951"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02198.java b/OWASP DATASET CLEANED/BenchmarkTest02198.java deleted file mode 100644 index a8a861b1c97aec0edaba3dc91a924bcf84609653..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02198.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02198") -public class BenchmarkTest02198 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02198"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02199.java b/OWASP DATASET CLEANED/BenchmarkTest02199.java deleted file mode 100644 index 50acae25ed9a83efab57c48e533005ef1770d376..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02199.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02199") -public class BenchmarkTest02199 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02199"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02200.java b/OWASP DATASET CLEANED/BenchmarkTest02200.java deleted file mode 100644 index 6c236bb09ddb7f093b04058bd1135b51e3744dc3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02200.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02200") -public class BenchmarkTest02200 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02200"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02201.java b/OWASP DATASET CLEANED/BenchmarkTest02201.java deleted file mode 100644 index 74ab7fdf5537e54745b1dd8beb8377f8408ed6b9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02201.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02201") -public class BenchmarkTest02201 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02201"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02202.java b/OWASP DATASET CLEANED/BenchmarkTest02202.java deleted file mode 100644 index 27047a2402d144b8382409f34414d7ad9327c751..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02202.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02202") -public class BenchmarkTest02202 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02202"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02203.java b/OWASP DATASET CLEANED/BenchmarkTest02203.java deleted file mode 100644 index 8de8cd1df0484c62134134b73ff42cd67fa84648..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02203.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02203") -public class BenchmarkTest02203 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02203"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a31470 = param; // assign - StringBuilder b31470 = new StringBuilder(a31470); // stick in stringbuilder - b31470.append(" SafeStuff"); // append some safe content - b31470.replace( - b31470.length() - "Chars".length(), - b31470.length(), - "Chars"); // replace some of the end content - java.util.HashMap map31470 = new java.util.HashMap(); - map31470.put("key31470", b31470.toString()); // put in a collection - String c31470 = (String) map31470.get("key31470"); // get it back out - String d31470 = c31470.substring(0, c31470.length() - 1); // extract most of it - String e31470 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d31470.getBytes()))); // B64 encode and decode it - String f31470 = e31470.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g31470 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g31470); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02204.java b/OWASP DATASET CLEANED/BenchmarkTest02204.java deleted file mode 100644 index 9ed94c10c5f53569f1635311216778eb33adb31f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02204.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02204") -public class BenchmarkTest02204 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02204"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02205.java b/OWASP DATASET CLEANED/BenchmarkTest02205.java deleted file mode 100644 index 220bc9b97f0ef2fbd56bb57583bb5926dc24b354..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02205.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02205") -public class BenchmarkTest02205 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02205"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02206.java b/OWASP DATASET CLEANED/BenchmarkTest02206.java deleted file mode 100644 index 0dacb5bbfb20ccc6fa0a744e42feb0df246c8659..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02206.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02206") -public class BenchmarkTest02206 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02206"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02207.java b/OWASP DATASET CLEANED/BenchmarkTest02207.java deleted file mode 100644 index 90bf5f29cc87d907611180b69b2b008ee71b4907..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02207.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02207") -public class BenchmarkTest02207 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02207"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02208.java b/OWASP DATASET CLEANED/BenchmarkTest02208.java deleted file mode 100644 index 525ff4177c3b13ddeef2f140090d2070cdbca6b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02208.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02208") -public class BenchmarkTest02208 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02208"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02209.java b/OWASP DATASET CLEANED/BenchmarkTest02209.java deleted file mode 100644 index 04857c88662ab2bf335d52d95c33da96d58693f0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02209.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02209") -public class BenchmarkTest02209 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02209"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02210.java b/OWASP DATASET CLEANED/BenchmarkTest02210.java deleted file mode 100644 index 36ac24eeba6530fd445016eb96dfd7f3115acacd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02210.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02210") -public class BenchmarkTest02210 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02210"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02211.java b/OWASP DATASET CLEANED/BenchmarkTest02211.java deleted file mode 100644 index 3ffcfafcee0a4067e434e8925a8c9153542a8141..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02211.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02211") -public class BenchmarkTest02211 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02211"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02212.java b/OWASP DATASET CLEANED/BenchmarkTest02212.java deleted file mode 100644 index 1f771b10ef8f24ceb220c1f9e03d504081b365a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02212.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02212") -public class BenchmarkTest02212 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02212"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02213.java b/OWASP DATASET CLEANED/BenchmarkTest02213.java deleted file mode 100644 index 77daec99cc9617a17bab0588041cc24fedc35285..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02213.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02213") -public class BenchmarkTest02213 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02213"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02214.java b/OWASP DATASET CLEANED/BenchmarkTest02214.java deleted file mode 100644 index 6f73bc8dc9ba7e3d1ed18d00dc2d85c3a9efbcda..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02214.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02214") -public class BenchmarkTest02214 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02214"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02215.java b/OWASP DATASET CLEANED/BenchmarkTest02215.java deleted file mode 100644 index 5a18cf9adb8e01a98c0b71325d9d0317f96c8d59..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02215.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02215") -public class BenchmarkTest02215 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02215"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02216.java b/OWASP DATASET CLEANED/BenchmarkTest02216.java deleted file mode 100644 index 70651e8d1d85c5a0d67f4a96876970827792cb5a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02216.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02216") -public class BenchmarkTest02216 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02216"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02217.java b/OWASP DATASET CLEANED/BenchmarkTest02217.java deleted file mode 100644 index 883c554f8d597699b2f3c5699c2932375f1bb303..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02217.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02217") -public class BenchmarkTest02217 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02217"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02218.java b/OWASP DATASET CLEANED/BenchmarkTest02218.java deleted file mode 100644 index e8cc9e4fd5f880ba04de104be750e8c0419e1873..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02218.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02218") -public class BenchmarkTest02218 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02218"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02219.java b/OWASP DATASET CLEANED/BenchmarkTest02219.java deleted file mode 100644 index 4841241de2e5df508bfeea67ba85863c31c5745e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02219.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02219") -public class BenchmarkTest02219 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02219"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02220.java b/OWASP DATASET CLEANED/BenchmarkTest02220.java deleted file mode 100644 index 6a44fec93b961fe5f2e895c20221eb7492fa9813..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02220.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02220") -public class BenchmarkTest02220 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02220"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a19972 = param; // assign - StringBuilder b19972 = new StringBuilder(a19972); // stick in stringbuilder - b19972.append(" SafeStuff"); // append some safe content - b19972.replace( - b19972.length() - "Chars".length(), - b19972.length(), - "Chars"); // replace some of the end content - java.util.HashMap map19972 = new java.util.HashMap(); - map19972.put("key19972", b19972.toString()); // put in a collection - String c19972 = (String) map19972.get("key19972"); // get it back out - String d19972 = c19972.substring(0, c19972.length() - 1); // extract most of it - String e19972 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d19972.getBytes()))); // B64 encode and decode it - String f19972 = e19972.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f19972); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02221.java b/OWASP DATASET CLEANED/BenchmarkTest02221.java deleted file mode 100644 index a3126d4620a2a4752cf784c4d8b24bdec4e19703..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02221.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02221") -public class BenchmarkTest02221 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02221"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz71523 = new StringBuilder(param); - bar = sbxyz71523.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02222.java b/OWASP DATASET CLEANED/BenchmarkTest02222.java deleted file mode 100644 index cfdd91c768d91adc776595a31983a488e612aa07..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02222.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02222") -public class BenchmarkTest02222 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02222"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02223.java b/OWASP DATASET CLEANED/BenchmarkTest02223.java deleted file mode 100644 index 29b691e1e827440385f81d1db69bc10ff9267e20..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02223.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02223") -public class BenchmarkTest02223 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02223"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz60073 = new StringBuilder(param); - String bar = sbxyz60073.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02224.java b/OWASP DATASET CLEANED/BenchmarkTest02224.java deleted file mode 100644 index a54b52255ae15df5ce7ddee97a27e4d46ac7696e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02224.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02224") -public class BenchmarkTest02224 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02224"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02225.java b/OWASP DATASET CLEANED/BenchmarkTest02225.java deleted file mode 100644 index a47a2df5371bece3ab262e3c89a8cb4578677e1f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02225.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02225") -public class BenchmarkTest02225 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02225"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map73885 = new java.util.HashMap(); - map73885.put("keyA-73885", "a-Value"); // put some stuff in the collection - map73885.put("keyB-73885", param); // put it in a collection - map73885.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map73885.get("keyB-73885"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02226.java b/OWASP DATASET CLEANED/BenchmarkTest02226.java deleted file mode 100644 index 91d6561f064995184a7b9afe3a192f314057c05f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02226.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02226") -public class BenchmarkTest02226 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02226"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02227.java b/OWASP DATASET CLEANED/BenchmarkTest02227.java deleted file mode 100644 index 4f3348255f5e70875e099cece7e60d240e8123ad..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02227.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02227") -public class BenchmarkTest02227 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02227"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz39187 = new StringBuilder(param); - String bar = sbxyz39187.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02228.java b/OWASP DATASET CLEANED/BenchmarkTest02228.java deleted file mode 100644 index 3343595760561707f5a6a7b69d1543a1523eda83..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02228.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02228") -public class BenchmarkTest02228 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02228"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz60124 = new StringBuilder(param); - String bar = sbxyz60124.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02229.java b/OWASP DATASET CLEANED/BenchmarkTest02229.java deleted file mode 100644 index 378334e7ccf1926837a9790e19fbdae4f83638f0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02229.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02229") -public class BenchmarkTest02229 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02229"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map26903 = new java.util.HashMap(); - map26903.put("keyA-26903", "a_Value"); // put some stuff in the collection - map26903.put("keyB-26903", param); // put it in a collection - map26903.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map26903.get("keyB-26903"); // get it back out - bar = (String) map26903.get("keyA-26903"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02230.java b/OWASP DATASET CLEANED/BenchmarkTest02230.java deleted file mode 100644 index fbf7949d3f9874fbe2b4e61d34dd0ba90980b4a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02230.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02230") -public class BenchmarkTest02230 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02230"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz51189 = new StringBuilder(param); - bar = sbxyz51189.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02231.java b/OWASP DATASET CLEANED/BenchmarkTest02231.java deleted file mode 100644 index 1f4f709ce865c7727715db2ad470b20ba60f52ca..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02231.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02231") -public class BenchmarkTest02231 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02231"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a60610 = param; // assign - StringBuilder b60610 = new StringBuilder(a60610); // stick in stringbuilder - b60610.append(" SafeStuff"); // append some safe content - b60610.replace( - b60610.length() - "Chars".length(), - b60610.length(), - "Chars"); // replace some of the end content - java.util.HashMap map60610 = new java.util.HashMap(); - map60610.put("key60610", b60610.toString()); // put in a collection - String c60610 = (String) map60610.get("key60610"); // get it back out - String d60610 = c60610.substring(0, c60610.length() - 1); // extract most of it - String e60610 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d60610.getBytes()))); // B64 encode and decode it - String f60610 = e60610.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g60610 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g60610); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02232.java b/OWASP DATASET CLEANED/BenchmarkTest02232.java deleted file mode 100644 index 889690033ee4cc895dd7a3b6bb451b72447f8a78..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02232.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02232") -public class BenchmarkTest02232 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02232"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02233.java b/OWASP DATASET CLEANED/BenchmarkTest02233.java deleted file mode 100644 index 4b418c452ed1fe5b64559cb84c4f8eab8b927483..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02233.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02233") -public class BenchmarkTest02233 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02233"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02234.java b/OWASP DATASET CLEANED/BenchmarkTest02234.java deleted file mode 100644 index 51cfa7074a951bf8b87a5785b9d3e18cb59a9e19..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02234.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02234") -public class BenchmarkTest02234 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02234"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz86132 = new StringBuilder(param); - String bar = sbxyz86132.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02235.java b/OWASP DATASET CLEANED/BenchmarkTest02235.java deleted file mode 100644 index afd2a82ebc3510f8425cc2285957efcd39de24bb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02235.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02235") -public class BenchmarkTest02235 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02235"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02236.java b/OWASP DATASET CLEANED/BenchmarkTest02236.java deleted file mode 100644 index 2c01bb9cfbea4ddcf5cd55bd2cc78cfbb63c23fd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02236.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02236") -public class BenchmarkTest02236 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02236"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02237.java b/OWASP DATASET CLEANED/BenchmarkTest02237.java deleted file mode 100644 index 1f4534030541673747cfd2ae34cb7350c2be0239..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02237.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02237") -public class BenchmarkTest02237 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02237"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02238.java b/OWASP DATASET CLEANED/BenchmarkTest02238.java deleted file mode 100644 index e5fd6cc5ef1070e16ea90c6f1beac5493d3125de..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02238.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02238") -public class BenchmarkTest02238 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02238"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a16227 = param; // assign - StringBuilder b16227 = new StringBuilder(a16227); // stick in stringbuilder - b16227.append(" SafeStuff"); // append some safe content - b16227.replace( - b16227.length() - "Chars".length(), - b16227.length(), - "Chars"); // replace some of the end content - java.util.HashMap map16227 = new java.util.HashMap(); - map16227.put("key16227", b16227.toString()); // put in a collection - String c16227 = (String) map16227.get("key16227"); // get it back out - String d16227 = c16227.substring(0, c16227.length() - 1); // extract most of it - String e16227 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d16227.getBytes()))); // B64 encode and decode it - String f16227 = e16227.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g16227 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g16227); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02239.java b/OWASP DATASET CLEANED/BenchmarkTest02239.java deleted file mode 100644 index e3ea0a13626d2504969a90425257268314e2bbe4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02239.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02239") -public class BenchmarkTest02239 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02239"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02240.java b/OWASP DATASET CLEANED/BenchmarkTest02240.java deleted file mode 100644 index 6fd426736b18db77ff91dbf9b797611ffb77604d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02240.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02240") -public class BenchmarkTest02240 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02240"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02241.java b/OWASP DATASET CLEANED/BenchmarkTest02241.java deleted file mode 100644 index a8c3da812d0091e5edd1b4a4d58d2702b7430ca6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02241.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02241") -public class BenchmarkTest02241 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02241"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02242.java b/OWASP DATASET CLEANED/BenchmarkTest02242.java deleted file mode 100644 index 00fc1f8ea8aeb834864b86d5543698803d690cb2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02242.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02242") -public class BenchmarkTest02242 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02242"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a91595 = param; // assign - StringBuilder b91595 = new StringBuilder(a91595); // stick in stringbuilder - b91595.append(" SafeStuff"); // append some safe content - b91595.replace( - b91595.length() - "Chars".length(), - b91595.length(), - "Chars"); // replace some of the end content - java.util.HashMap map91595 = new java.util.HashMap(); - map91595.put("key91595", b91595.toString()); // put in a collection - String c91595 = (String) map91595.get("key91595"); // get it back out - String d91595 = c91595.substring(0, c91595.length() - 1); // extract most of it - String e91595 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d91595.getBytes()))); // B64 encode and decode it - String f91595 = e91595.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g91595 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g91595); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02243.java b/OWASP DATASET CLEANED/BenchmarkTest02243.java deleted file mode 100644 index 40c8c4f56d54d79cfcfd20b83a47e415c93a6168..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02243.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02243") -public class BenchmarkTest02243 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02243"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map19941 = new java.util.HashMap(); - map19941.put("keyA-19941", "a-Value"); // put some stuff in the collection - map19941.put("keyB-19941", param); // put it in a collection - map19941.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map19941.get("keyB-19941"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02244.java b/OWASP DATASET CLEANED/BenchmarkTest02244.java deleted file mode 100644 index 6cb12a71ac80a71c46113e39fee7a6d8f6ab3aec..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02244.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02244") -public class BenchmarkTest02244 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02244"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02245.java b/OWASP DATASET CLEANED/BenchmarkTest02245.java deleted file mode 100644 index 0d8dd4aaf590eaa2d58cb661c0a62c6c245a20ab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02245.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02245") -public class BenchmarkTest02245 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02245"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02246.java b/OWASP DATASET CLEANED/BenchmarkTest02246.java deleted file mode 100644 index e5af1bea0b2372288c2ecb9d501e551cf004eb9e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02246.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02246") -public class BenchmarkTest02246 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02246"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map19712 = new java.util.HashMap(); - map19712.put("keyA-19712", "a-Value"); // put some stuff in the collection - map19712.put("keyB-19712", param); // put it in a collection - map19712.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map19712.get("keyB-19712"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02247.java b/OWASP DATASET CLEANED/BenchmarkTest02247.java deleted file mode 100644 index 3d83683a62ee8a49bfbb3060b2a5c6391468e561..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02247.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02247") -public class BenchmarkTest02247 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02247"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02248.java b/OWASP DATASET CLEANED/BenchmarkTest02248.java deleted file mode 100644 index f88028346c55610b291bb0b4bbdf43c55c51b8a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02248.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02248") -public class BenchmarkTest02248 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02248"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02249.java b/OWASP DATASET CLEANED/BenchmarkTest02249.java deleted file mode 100644 index 5c16c13b0fa7cfa58769747e118037d1f3f503d9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02249.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02249") -public class BenchmarkTest02249 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02249"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02250.java b/OWASP DATASET CLEANED/BenchmarkTest02250.java deleted file mode 100644 index e947d603241789c2866da1fc2a8ae025fc1ecb17..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02250.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02250") -public class BenchmarkTest02250 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02250"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map94176 = new java.util.HashMap(); - map94176.put("keyA-94176", "a-Value"); // put some stuff in the collection - map94176.put("keyB-94176", param); // put it in a collection - map94176.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map94176.get("keyB-94176"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02251.java b/OWASP DATASET CLEANED/BenchmarkTest02251.java deleted file mode 100644 index 3dfcbd51e745cbc154d98b92a1ae73ad649abe4f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02251.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02251") -public class BenchmarkTest02251 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02251"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02252.java b/OWASP DATASET CLEANED/BenchmarkTest02252.java deleted file mode 100644 index 46abd6c4b3e1a1aca5dc2435ea9eee219e5e64c0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02252.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02252") -public class BenchmarkTest02252 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02252"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02253.java b/OWASP DATASET CLEANED/BenchmarkTest02253.java deleted file mode 100644 index af4e1adea3ee8ec9d0dddb192fafe51c2660f2df..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02253.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02253") -public class BenchmarkTest02253 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02253"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02254.java b/OWASP DATASET CLEANED/BenchmarkTest02254.java deleted file mode 100644 index 31b1eaeb60459f787cd8d62211d3f716dca89435..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02254.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02254") -public class BenchmarkTest02254 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02254"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02255.java b/OWASP DATASET CLEANED/BenchmarkTest02255.java deleted file mode 100644 index 660600aca474fdfbe92c912784d13761e2d887a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02255.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02255") -public class BenchmarkTest02255 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02255"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02256.java b/OWASP DATASET CLEANED/BenchmarkTest02256.java deleted file mode 100644 index df1ba88e2d357d7ef3583284f66487a4e7bca5d8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02256.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02256") -public class BenchmarkTest02256 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02256"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02257.java b/OWASP DATASET CLEANED/BenchmarkTest02257.java deleted file mode 100644 index 0a6049a61929b5152b777e7bfac2a2fff9bede55..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02257.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02257") -public class BenchmarkTest02257 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02257"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02258.java b/OWASP DATASET CLEANED/BenchmarkTest02258.java deleted file mode 100644 index 1fa609c60ce4bb908621ae3ca1c8d94ee2ab327f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02258.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02258") -public class BenchmarkTest02258 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02258"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02259.java b/OWASP DATASET CLEANED/BenchmarkTest02259.java deleted file mode 100644 index 19a160492685a57ae5817a7fe30537fb05897224..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02259.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02259") -public class BenchmarkTest02259 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02259"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02260.java b/OWASP DATASET CLEANED/BenchmarkTest02260.java deleted file mode 100644 index c8c5efeea5dd2d6f72a7321407d3dd1627a0a4fb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02260.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02260") -public class BenchmarkTest02260 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02260"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02261.java b/OWASP DATASET CLEANED/BenchmarkTest02261.java deleted file mode 100644 index 878ef493c3eb49a035164d0066d44fa449604e8a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02261.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02261") -public class BenchmarkTest02261 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02261"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02262.java b/OWASP DATASET CLEANED/BenchmarkTest02262.java deleted file mode 100644 index 81b2be77bd363d0c15b2d3f0386767f99a2c3f76..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02262.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02262") -public class BenchmarkTest02262 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02262"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02263.java b/OWASP DATASET CLEANED/BenchmarkTest02263.java deleted file mode 100644 index 3601a35df396044611797be9b526613e66ad9d29..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02263.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02263") -public class BenchmarkTest02263 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02263"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02264.java b/OWASP DATASET CLEANED/BenchmarkTest02264.java deleted file mode 100644 index ae2d93b9a2f7a4a7f19bcb05f896c0f7d70f4788..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02264.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02264") -public class BenchmarkTest02264 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02264"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02265.java b/OWASP DATASET CLEANED/BenchmarkTest02265.java deleted file mode 100644 index 01b61fe0013a3be4cc9d2df0540f23579b2cb460..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02265.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02265") -public class BenchmarkTest02265 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02265"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02266.java b/OWASP DATASET CLEANED/BenchmarkTest02266.java deleted file mode 100644 index e43009b44378f47a6a92b5cfd3fe11d9d1fb79a2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02266.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02266") -public class BenchmarkTest02266 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02266"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02267.java b/OWASP DATASET CLEANED/BenchmarkTest02267.java deleted file mode 100644 index 5f87994cb96f512e70ba3c33c551228d47737986..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02267.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02267") -public class BenchmarkTest02267 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02267"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02268.java b/OWASP DATASET CLEANED/BenchmarkTest02268.java deleted file mode 100644 index 515184a32690f01782c5f0270d5de04df564b3cb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02268.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02268") -public class BenchmarkTest02268 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02268"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map95440 = new java.util.HashMap(); - map95440.put("keyA-95440", "a_Value"); // put some stuff in the collection - map95440.put("keyB-95440", param); // put it in a collection - map95440.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map95440.get("keyB-95440"); // get it back out - bar = (String) map95440.get("keyA-95440"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02269.java b/OWASP DATASET CLEANED/BenchmarkTest02269.java deleted file mode 100644 index b90b184768dcfb10ec661dd7afa4a5babe4cd068..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02269.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02269") -public class BenchmarkTest02269 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02269"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02270.java b/OWASP DATASET CLEANED/BenchmarkTest02270.java deleted file mode 100644 index d11e5ede3e7ff2a8a4b597959778d30d37f0295a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02270.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02270") -public class BenchmarkTest02270 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02270"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02271.java b/OWASP DATASET CLEANED/BenchmarkTest02271.java deleted file mode 100644 index 1b90bd2cc9d587f786de6493787b6853ad383e79..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02271.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02271") -public class BenchmarkTest02271 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02271"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new int[] {1, 2}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02272.java b/OWASP DATASET CLEANED/BenchmarkTest02272.java deleted file mode 100644 index 68c4bfaf57a928b43675fb7242e27faac9c205d8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02272.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02272") -public class BenchmarkTest02272 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02272"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02273.java b/OWASP DATASET CLEANED/BenchmarkTest02273.java deleted file mode 100644 index 609d991b973f33c11cdbbf49484fac5d85f1fc23..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02273.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02273") -public class BenchmarkTest02273 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02273"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02274.java b/OWASP DATASET CLEANED/BenchmarkTest02274.java deleted file mode 100644 index 4c346dbd5bf004e6c024b8b86af4a211211ab5e2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02274.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02274") -public class BenchmarkTest02274 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02274"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02275.java b/OWASP DATASET CLEANED/BenchmarkTest02275.java deleted file mode 100644 index d9c2334a7c44fad9b84a45cbd8b5cb41e1bcab63..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02275.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-04/BenchmarkTest02275") -public class BenchmarkTest02275 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02275"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02276.java b/OWASP DATASET CLEANED/BenchmarkTest02276.java deleted file mode 100644 index a36ec164faaf0ebfc45b30f59151749d9177b1a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02276.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02276") -public class BenchmarkTest02276 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02276"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // int results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql); - Integer results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Integer.class); - response.getWriter().println("Your results are: " + results); - // System.out.println("Your results are: " + results); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02277.java b/OWASP DATASET CLEANED/BenchmarkTest02277.java deleted file mode 100644 index b67c1299896da9e0e54d5cd563af51e95dd7251e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02277.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02277") -public class BenchmarkTest02277 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02277"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02278.java b/OWASP DATASET CLEANED/BenchmarkTest02278.java deleted file mode 100644 index 1151848a297235d72694054c5b6f6a9e3ce57441..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02278.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02278") -public class BenchmarkTest02278 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02278"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map96698 = new java.util.HashMap(); - map96698.put("keyA-96698", "a_Value"); // put some stuff in the collection - map96698.put("keyB-96698", param); // put it in a collection - map96698.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map96698.get("keyB-96698"); // get it back out - bar = (String) map96698.get("keyA-96698"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02279.java b/OWASP DATASET CLEANED/BenchmarkTest02279.java deleted file mode 100644 index e2d980e42d5e6b068a3921c59dfcb1a435763e44..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02279.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02279") -public class BenchmarkTest02279 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02279"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02280.java b/OWASP DATASET CLEANED/BenchmarkTest02280.java deleted file mode 100644 index 1fbe5c6fb8f1fe0d9258be1a383ba713860c398e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02280.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02280") -public class BenchmarkTest02280 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02280"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02281.java b/OWASP DATASET CLEANED/BenchmarkTest02281.java deleted file mode 100644 index 7c5807700b1ad63f495970aa6df4a4c4ca96dd23..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02281.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02281") -public class BenchmarkTest02281 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02281"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02282.java b/OWASP DATASET CLEANED/BenchmarkTest02282.java deleted file mode 100644 index e1feed1ebfa176f930bfca08182724104f896aa8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02282.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02282") -public class BenchmarkTest02282 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02282"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02283.java b/OWASP DATASET CLEANED/BenchmarkTest02283.java deleted file mode 100644 index 706b0737042164faac323202d63718ad2168e656..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02283.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02283") -public class BenchmarkTest02283 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02283"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02284.java b/OWASP DATASET CLEANED/BenchmarkTest02284.java deleted file mode 100644 index 780d7601916ec62af1fd42f65877f713d8282e07..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02284.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02284") -public class BenchmarkTest02284 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02284"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02285.java b/OWASP DATASET CLEANED/BenchmarkTest02285.java deleted file mode 100644 index 5526d425eb8b7aea6751a50b4930e9bf83466252..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02285.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02285") -public class BenchmarkTest02285 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02285"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02286.java b/OWASP DATASET CLEANED/BenchmarkTest02286.java deleted file mode 100644 index beb83e124a563a55c8217df98945eaf299b64f2a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02286.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02286") -public class BenchmarkTest02286 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02286"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02287.java b/OWASP DATASET CLEANED/BenchmarkTest02287.java deleted file mode 100644 index a32f27fbaefe83271b3ab649b4b5d7065c7f3a3d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02287.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02287") -public class BenchmarkTest02287 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02287"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02288.java b/OWASP DATASET CLEANED/BenchmarkTest02288.java deleted file mode 100644 index 2a71006a55b492c2cdee753a2ee4217ac768194a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02288.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02288") -public class BenchmarkTest02288 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - java.util.Map map = request.getParameterMap(); - String param = ""; - if (!map.isEmpty()) { - String[] values = map.get("BenchmarkTest02288"); - if (values != null) param = values[0]; - } - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02289.java b/OWASP DATASET CLEANED/BenchmarkTest02289.java deleted file mode 100644 index 5cc4e2ad3172ed71ca0a2bfe2ab03c5f4d93ba6a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02289.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02289") -public class BenchmarkTest02289 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02289")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02290.java b/OWASP DATASET CLEANED/BenchmarkTest02290.java deleted file mode 100644 index e14dfb145c8773b5a67da19b8b90ff62f7ed1d94..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02290.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02290") -public class BenchmarkTest02290 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02290")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02291.java b/OWASP DATASET CLEANED/BenchmarkTest02291.java deleted file mode 100644 index 29b5c42fae95a5a423097d1756cf2b5d8c00ebc6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02291.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02291") -public class BenchmarkTest02291 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02291")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a10347 = param; // assign - StringBuilder b10347 = new StringBuilder(a10347); // stick in stringbuilder - b10347.append(" SafeStuff"); // append some safe content - b10347.replace( - b10347.length() - "Chars".length(), - b10347.length(), - "Chars"); // replace some of the end content - java.util.HashMap map10347 = new java.util.HashMap(); - map10347.put("key10347", b10347.toString()); // put in a collection - String c10347 = (String) map10347.get("key10347"); // get it back out - String d10347 = c10347.substring(0, c10347.length() - 1); // extract most of it - String e10347 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d10347.getBytes()))); // B64 encode and decode it - String f10347 = e10347.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g10347 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g10347); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02292.java b/OWASP DATASET CLEANED/BenchmarkTest02292.java deleted file mode 100644 index 1af53015f7d52254e08217d6839f30a6abc15a3c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02292.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02292") -public class BenchmarkTest02292 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02292")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02293.java b/OWASP DATASET CLEANED/BenchmarkTest02293.java deleted file mode 100644 index 2e60ca00ebeb3467b33492714ccce9277ff3cfe6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02293.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02293") -public class BenchmarkTest02293 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02293")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a87246 = param; // assign - StringBuilder b87246 = new StringBuilder(a87246); // stick in stringbuilder - b87246.append(" SafeStuff"); // append some safe content - b87246.replace( - b87246.length() - "Chars".length(), - b87246.length(), - "Chars"); // replace some of the end content - java.util.HashMap map87246 = new java.util.HashMap(); - map87246.put("key87246", b87246.toString()); // put in a collection - String c87246 = (String) map87246.get("key87246"); // get it back out - String d87246 = c87246.substring(0, c87246.length() - 1); // extract most of it - String e87246 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d87246.getBytes()))); // B64 encode and decode it - String f87246 = e87246.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f87246); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02294.java b/OWASP DATASET CLEANED/BenchmarkTest02294.java deleted file mode 100644 index fa052c473b0158138c6b00c1b44a28127104e7b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02294.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02294") -public class BenchmarkTest02294 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02294")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02295.java b/OWASP DATASET CLEANED/BenchmarkTest02295.java deleted file mode 100644 index 142d9c58560854f4635b21dcf8ad43710282e4eb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02295.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02295") -public class BenchmarkTest02295 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02295")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02296.java b/OWASP DATASET CLEANED/BenchmarkTest02296.java deleted file mode 100644 index 8efd4c98f20e6e7de9b216d9fe96dea88c7f4bc4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02296.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02296") -public class BenchmarkTest02296 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02296")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02297.java b/OWASP DATASET CLEANED/BenchmarkTest02297.java deleted file mode 100644 index cd84ea0af0fff0647ceede65f93083065c67eda5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02297.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02297") -public class BenchmarkTest02297 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02297")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02298.java b/OWASP DATASET CLEANED/BenchmarkTest02298.java deleted file mode 100644 index 50be70b0a1d3e2b9b7030e848e48b0e6774f4223..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02298.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02298") -public class BenchmarkTest02298 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02298")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02299.java b/OWASP DATASET CLEANED/BenchmarkTest02299.java deleted file mode 100644 index 2522d0ae52f77bf762a0c3914f02a4287b789a26..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02299.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02299") -public class BenchmarkTest02299 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02299")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02300.java b/OWASP DATASET CLEANED/BenchmarkTest02300.java deleted file mode 100644 index 1d883440754871410f4c001934026379ab512319..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02300.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02300") -public class BenchmarkTest02300 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02300")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a20919 = param; // assign - StringBuilder b20919 = new StringBuilder(a20919); // stick in stringbuilder - b20919.append(" SafeStuff"); // append some safe content - b20919.replace( - b20919.length() - "Chars".length(), - b20919.length(), - "Chars"); // replace some of the end content - java.util.HashMap map20919 = new java.util.HashMap(); - map20919.put("key20919", b20919.toString()); // put in a collection - String c20919 = (String) map20919.get("key20919"); // get it back out - String d20919 = c20919.substring(0, c20919.length() - 1); // extract most of it - String e20919 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d20919.getBytes()))); // B64 encode and decode it - String f20919 = e20919.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g20919 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g20919); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02301.java b/OWASP DATASET CLEANED/BenchmarkTest02301.java deleted file mode 100644 index afb8cf481e799b56dcff97fcc15f759baac682b4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02301.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02301") -public class BenchmarkTest02301 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02301")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02302.java b/OWASP DATASET CLEANED/BenchmarkTest02302.java deleted file mode 100644 index 2cfed217e0b092fcc80e269c67c4320e5c11cff8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02302.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02302") -public class BenchmarkTest02302 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02302")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02303.java b/OWASP DATASET CLEANED/BenchmarkTest02303.java deleted file mode 100644 index 0fcb18184f755157de9443a95423d2e24d2232ca..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02303.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02303") -public class BenchmarkTest02303 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02303")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02304.java b/OWASP DATASET CLEANED/BenchmarkTest02304.java deleted file mode 100644 index d9f6242502e5a31612ca0f420d965d369448e0ec..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02304.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02304") -public class BenchmarkTest02304 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02304")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02305.java b/OWASP DATASET CLEANED/BenchmarkTest02305.java deleted file mode 100644 index 7601ee638cca1ce809040c1e8aa17e202ec2b104..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02305.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02305") -public class BenchmarkTest02305 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02305")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02306.java b/OWASP DATASET CLEANED/BenchmarkTest02306.java deleted file mode 100644 index 1d825bed3de95bbe548fc377030152639a63b51b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02306.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02306") -public class BenchmarkTest02306 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02306")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02307.java b/OWASP DATASET CLEANED/BenchmarkTest02307.java deleted file mode 100644 index 5c129c93e7d930f8ed9ac9fa098c8d9b7d9c1973..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02307.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02307") -public class BenchmarkTest02307 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02307")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02308.java b/OWASP DATASET CLEANED/BenchmarkTest02308.java deleted file mode 100644 index 1f3b3119f7cc230e17fdb1e401450a0c1505e5e2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02308.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02308") -public class BenchmarkTest02308 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02308")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02309.java b/OWASP DATASET CLEANED/BenchmarkTest02309.java deleted file mode 100644 index 6256fbbc4e5f76567d4fadd93de1c1622ae257cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02309.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02309") -public class BenchmarkTest02309 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02309")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02310.java b/OWASP DATASET CLEANED/BenchmarkTest02310.java deleted file mode 100644 index 8c6962fb5a742d75f2c94a1c4ebb55ebe9d1de57..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02310.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02310") -public class BenchmarkTest02310 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02310")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = - java.security.MessageDigest.getInstance("SHA-512", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02311.java b/OWASP DATASET CLEANED/BenchmarkTest02311.java deleted file mode 100644 index 07fb539af13a8835d905f6bad74e5c69c965f4ae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02311.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02311") -public class BenchmarkTest02311 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02311")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02312.java b/OWASP DATASET CLEANED/BenchmarkTest02312.java deleted file mode 100644 index ffaa394678631971da4143fb1649f94245434647..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02312.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02312") -public class BenchmarkTest02312 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02312")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02313.java b/OWASP DATASET CLEANED/BenchmarkTest02313.java deleted file mode 100644 index a3d2ff8f6767f422b1df705649001ccbcaea10a0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02313.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02313") -public class BenchmarkTest02313 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02313")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a31085 = param; // assign - StringBuilder b31085 = new StringBuilder(a31085); // stick in stringbuilder - b31085.append(" SafeStuff"); // append some safe content - b31085.replace( - b31085.length() - "Chars".length(), - b31085.length(), - "Chars"); // replace some of the end content - java.util.HashMap map31085 = new java.util.HashMap(); - map31085.put("key31085", b31085.toString()); // put in a collection - String c31085 = (String) map31085.get("key31085"); // get it back out - String d31085 = c31085.substring(0, c31085.length() - 1); // extract most of it - String e31085 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d31085.getBytes()))); // B64 encode and decode it - String f31085 = e31085.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g31085 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g31085); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02314.java b/OWASP DATASET CLEANED/BenchmarkTest02314.java deleted file mode 100644 index a316c45b166eea2cf3637611fa8e9ca2441b2ad3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02314.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02314") -public class BenchmarkTest02314 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02314")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02315.java b/OWASP DATASET CLEANED/BenchmarkTest02315.java deleted file mode 100644 index fbae22cd9a81ffd498005558904cc448cb6f2833..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02315.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02315") -public class BenchmarkTest02315 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02315")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02316.java b/OWASP DATASET CLEANED/BenchmarkTest02316.java deleted file mode 100644 index b6cdf9f2c21b3ad0ec1615635dc3b2fc00c95470..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02316.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02316") -public class BenchmarkTest02316 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02316")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02317.java b/OWASP DATASET CLEANED/BenchmarkTest02317.java deleted file mode 100644 index 3d576ae779fac18304bc7d862cdf2bd1b964e5ff..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02317.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02317") -public class BenchmarkTest02317 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02317")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02318.java b/OWASP DATASET CLEANED/BenchmarkTest02318.java deleted file mode 100644 index 2cebfb4ca17b35c3ec8ed8d48f492ac1cb625c7b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02318.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02318") -public class BenchmarkTest02318 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02318")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02319.java b/OWASP DATASET CLEANED/BenchmarkTest02319.java deleted file mode 100644 index 2a77061f7120ad3871d17d85fcafc986e19722c0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02319.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02319") -public class BenchmarkTest02319 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02319")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02320.java b/OWASP DATASET CLEANED/BenchmarkTest02320.java deleted file mode 100644 index 9c37f389d8fd1a93f21c49b506b08e0f575910da..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02320.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02320") -public class BenchmarkTest02320 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02320")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02321.java b/OWASP DATASET CLEANED/BenchmarkTest02321.java deleted file mode 100644 index 4f527b58bb79e7057efa096aac2c143579b17e54..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02321.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02321") -public class BenchmarkTest02321 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02321")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a32510 = param; // assign - StringBuilder b32510 = new StringBuilder(a32510); // stick in stringbuilder - b32510.append(" SafeStuff"); // append some safe content - b32510.replace( - b32510.length() - "Chars".length(), - b32510.length(), - "Chars"); // replace some of the end content - java.util.HashMap map32510 = new java.util.HashMap(); - map32510.put("key32510", b32510.toString()); // put in a collection - String c32510 = (String) map32510.get("key32510"); // get it back out - String d32510 = c32510.substring(0, c32510.length() - 1); // extract most of it - String e32510 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d32510.getBytes()))); // B64 encode and decode it - String f32510 = e32510.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f32510); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02322.java b/OWASP DATASET CLEANED/BenchmarkTest02322.java deleted file mode 100644 index dcf3ffcd50de224ce963119cb44d6c4af7d5a19c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02322.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02322") -public class BenchmarkTest02322 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02322")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02323.java b/OWASP DATASET CLEANED/BenchmarkTest02323.java deleted file mode 100644 index 31d098e21f3e8945a1f746757e855ee81d80a1ff..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02323.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02323") -public class BenchmarkTest02323 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02323")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02324.java b/OWASP DATASET CLEANED/BenchmarkTest02324.java deleted file mode 100644 index 86615b1cfe28c0fee97bf57e0425b8dc32dcae6a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02324.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02324") -public class BenchmarkTest02324 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02324")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz12198 = new StringBuilder(param); - bar = sbxyz12198.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02325.java b/OWASP DATASET CLEANED/BenchmarkTest02325.java deleted file mode 100644 index 6585944f60a04562ed3c11f1c93229ec85de78fc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02325.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02325") -public class BenchmarkTest02325 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02325")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02326.java b/OWASP DATASET CLEANED/BenchmarkTest02326.java deleted file mode 100644 index 12f0c989101eaee3eae02ac1001a24f53b7a0179..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02326.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02326") -public class BenchmarkTest02326 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02326")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02327.java b/OWASP DATASET CLEANED/BenchmarkTest02327.java deleted file mode 100644 index 3e362aa96056db3b4601ff4fcff5b97a29442548..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02327.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02327") -public class BenchmarkTest02327 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02327")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02328.java b/OWASP DATASET CLEANED/BenchmarkTest02328.java deleted file mode 100644 index e20b9eaeb02bf0631c4ff4c2e4438b274012e74a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02328.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02328") -public class BenchmarkTest02328 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02328")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02329.java b/OWASP DATASET CLEANED/BenchmarkTest02329.java deleted file mode 100644 index ffb545dd9c30d65930d1d085301b1b83031b1515..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02329.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02329") -public class BenchmarkTest02329 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02329")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02330.java b/OWASP DATASET CLEANED/BenchmarkTest02330.java deleted file mode 100644 index 1259b3c435695c72fba9485f8cf0528ac7434ef6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02330.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02330") -public class BenchmarkTest02330 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02330")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02331.java b/OWASP DATASET CLEANED/BenchmarkTest02331.java deleted file mode 100644 index c04d29e3aefa4edf076ba14b10ceafa00fc9331c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02331.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02331") -public class BenchmarkTest02331 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02331")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02332.java b/OWASP DATASET CLEANED/BenchmarkTest02332.java deleted file mode 100644 index 08648f3ec1ab819402ab0df261b6b39036378f0c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02332.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02332") -public class BenchmarkTest02332 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02332")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02333.java b/OWASP DATASET CLEANED/BenchmarkTest02333.java deleted file mode 100644 index 166124a7d35db8c51544d1c668a3de7cdb2cf73d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02333.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02333") -public class BenchmarkTest02333 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02333")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02334.java b/OWASP DATASET CLEANED/BenchmarkTest02334.java deleted file mode 100644 index b10cfd64408c7938291edfe5cc3a0d6b53775e18..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02334.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02334") -public class BenchmarkTest02334 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02334")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02335.java b/OWASP DATASET CLEANED/BenchmarkTest02335.java deleted file mode 100644 index 688df877eb9f9c52d4cdbd2d8a486ca72abc24b7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02335.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02335") -public class BenchmarkTest02335 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02335")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02336.java b/OWASP DATASET CLEANED/BenchmarkTest02336.java deleted file mode 100644 index 2af709a152306b484bc22727194ac69b35a1951f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02336.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02336") -public class BenchmarkTest02336 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02336")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a61280 = param; // assign - StringBuilder b61280 = new StringBuilder(a61280); // stick in stringbuilder - b61280.append(" SafeStuff"); // append some safe content - b61280.replace( - b61280.length() - "Chars".length(), - b61280.length(), - "Chars"); // replace some of the end content - java.util.HashMap map61280 = new java.util.HashMap(); - map61280.put("key61280", b61280.toString()); // put in a collection - String c61280 = (String) map61280.get("key61280"); // get it back out - String d61280 = c61280.substring(0, c61280.length() - 1); // extract most of it - String e61280 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d61280.getBytes()))); // B64 encode and decode it - String f61280 = e61280.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g61280 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g61280); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02337.java b/OWASP DATASET CLEANED/BenchmarkTest02337.java deleted file mode 100644 index ea499a3bb6530dd4e6ef03b0b48b5d6bb1df415b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02337.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02337") -public class BenchmarkTest02337 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02337")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map19180 = new java.util.HashMap(); - map19180.put("keyA-19180", "a_Value"); // put some stuff in the collection - map19180.put("keyB-19180", param); // put it in a collection - map19180.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map19180.get("keyB-19180"); // get it back out - bar = (String) map19180.get("keyA-19180"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02338.java b/OWASP DATASET CLEANED/BenchmarkTest02338.java deleted file mode 100644 index 281b2801980487b0613989091505ef7fb2647000..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02338.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02338") -public class BenchmarkTest02338 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02338")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02339.java b/OWASP DATASET CLEANED/BenchmarkTest02339.java deleted file mode 100644 index e646a315db1c1fb78e973d3aeceee99f1bf0c1ba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02339.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02339") -public class BenchmarkTest02339 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02339")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02340.java b/OWASP DATASET CLEANED/BenchmarkTest02340.java deleted file mode 100644 index 13d2fa7b84087978f5d98eb6b5a8056271b85b9d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02340.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02340") -public class BenchmarkTest02340 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02340")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02341.java b/OWASP DATASET CLEANED/BenchmarkTest02341.java deleted file mode 100644 index 49b536124c1376da6589861d2c07dc014d9c255f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02341.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02341") -public class BenchmarkTest02341 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02341")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02342.java b/OWASP DATASET CLEANED/BenchmarkTest02342.java deleted file mode 100644 index 98298d0e8345d5418f7ce7994081c340c367960c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02342.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02342") -public class BenchmarkTest02342 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02342")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02343.java b/OWASP DATASET CLEANED/BenchmarkTest02343.java deleted file mode 100644 index 2e59856914469f1951999fd76df84188a9ffd5ab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02343.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02343") -public class BenchmarkTest02343 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02343")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - String[] argsEnv = {"Foo=bar"}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = - r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02344.java b/OWASP DATASET CLEANED/BenchmarkTest02344.java deleted file mode 100644 index c100520735852e0bfe7719d824b7ca730391e642..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02344.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02344") -public class BenchmarkTest02344 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02344")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02345.java b/OWASP DATASET CLEANED/BenchmarkTest02345.java deleted file mode 100644 index 165edef205140b95bf937c751088e9e568150960..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02345.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02345") -public class BenchmarkTest02345 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02345")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map60514 = new java.util.HashMap(); - map60514.put("keyA-60514", "a-Value"); // put some stuff in the collection - map60514.put("keyB-60514", param); // put it in a collection - map60514.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map60514.get("keyB-60514"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02346.java b/OWASP DATASET CLEANED/BenchmarkTest02346.java deleted file mode 100644 index 17fcbac920e16b782b53a58a69e74a5ecdfda941..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02346.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02346") -public class BenchmarkTest02346 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02346")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz9692 = new StringBuilder(param); - bar = sbxyz9692.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02347.java b/OWASP DATASET CLEANED/BenchmarkTest02347.java deleted file mode 100644 index 5186e11fb8b527a0c54da3084b24bedee555c4c4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02347.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02347") -public class BenchmarkTest02347 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02347")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02348.java b/OWASP DATASET CLEANED/BenchmarkTest02348.java deleted file mode 100644 index 7d19540d2546aff83772f477b9a559412ee51c12..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02348.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02348") -public class BenchmarkTest02348 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02348")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map48532 = new java.util.HashMap(); - map48532.put("keyA-48532", "a-Value"); // put some stuff in the collection - map48532.put("keyB-48532", param); // put it in a collection - map48532.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map48532.get("keyB-48532"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02349.java b/OWASP DATASET CLEANED/BenchmarkTest02349.java deleted file mode 100644 index d7008564b1817ac8d0c3c94ccafda85369424c5a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02349.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02349") -public class BenchmarkTest02349 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02349")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a55770 = param; // assign - StringBuilder b55770 = new StringBuilder(a55770); // stick in stringbuilder - b55770.append(" SafeStuff"); // append some safe content - b55770.replace( - b55770.length() - "Chars".length(), - b55770.length(), - "Chars"); // replace some of the end content - java.util.HashMap map55770 = new java.util.HashMap(); - map55770.put("key55770", b55770.toString()); // put in a collection - String c55770 = (String) map55770.get("key55770"); // get it back out - String d55770 = c55770.substring(0, c55770.length() - 1); // extract most of it - String e55770 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d55770.getBytes()))); // B64 encode and decode it - String f55770 = e55770.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f55770); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02350.java b/OWASP DATASET CLEANED/BenchmarkTest02350.java deleted file mode 100644 index d7e86659825bfe4206f9a3daa7321bbad3ab0c74..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02350.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02350") -public class BenchmarkTest02350 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02350")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02351.java b/OWASP DATASET CLEANED/BenchmarkTest02351.java deleted file mode 100644 index d151c548ea81ad0ae0fec1d60f9390d2e40aecaa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02351.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02351") -public class BenchmarkTest02351 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02351")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a14991 = param; // assign - StringBuilder b14991 = new StringBuilder(a14991); // stick in stringbuilder - b14991.append(" SafeStuff"); // append some safe content - b14991.replace( - b14991.length() - "Chars".length(), - b14991.length(), - "Chars"); // replace some of the end content - java.util.HashMap map14991 = new java.util.HashMap(); - map14991.put("key14991", b14991.toString()); // put in a collection - String c14991 = (String) map14991.get("key14991"); // get it back out - String d14991 = c14991.substring(0, c14991.length() - 1); // extract most of it - String e14991 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d14991.getBytes()))); // B64 encode and decode it - String f14991 = e14991.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f14991); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02352.java b/OWASP DATASET CLEANED/BenchmarkTest02352.java deleted file mode 100644 index f6d1dbfb61ab9b0c9d0d2550ade2490c7e144d79..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02352.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02352") -public class BenchmarkTest02352 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02352")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02353.java b/OWASP DATASET CLEANED/BenchmarkTest02353.java deleted file mode 100644 index 2e8bb2bfd1fb3c79477e192ae49025cd21226705..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02353.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02353") -public class BenchmarkTest02353 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02353")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02354.java b/OWASP DATASET CLEANED/BenchmarkTest02354.java deleted file mode 100644 index 37184ef31a1e87cf836341e323269784f9c3467e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02354.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02354") -public class BenchmarkTest02354 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02354")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new int[] {1, 2}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02355.java b/OWASP DATASET CLEANED/BenchmarkTest02355.java deleted file mode 100644 index 18b0317f6137114219e668340f5ddf0935283f12..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02355.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02355") -public class BenchmarkTest02355 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02355")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02356.java b/OWASP DATASET CLEANED/BenchmarkTest02356.java deleted file mode 100644 index 3d8897e46ac16e298da3eb3bd30e6042ec386136..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02356.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02356") -public class BenchmarkTest02356 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02356")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02357.java b/OWASP DATASET CLEANED/BenchmarkTest02357.java deleted file mode 100644 index e825dc3671c587d1d1f41fa10304a2e28bbcdb3d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02357.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02357") -public class BenchmarkTest02357 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02357")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02358.java b/OWASP DATASET CLEANED/BenchmarkTest02358.java deleted file mode 100644 index fbd6824e6a567d5bb2dcb1885a82950fb4783331..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02358.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02358") -public class BenchmarkTest02358 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02358")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02359.java b/OWASP DATASET CLEANED/BenchmarkTest02359.java deleted file mode 100644 index 627118f90449456b0ea521f5a79f785530479480..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02359.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02359") -public class BenchmarkTest02359 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02359")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02360.java b/OWASP DATASET CLEANED/BenchmarkTest02360.java deleted file mode 100644 index 7ee083d7e52cb33b023a9e7f32d303687d0d456c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02360.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02360") -public class BenchmarkTest02360 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02360")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02361.java b/OWASP DATASET CLEANED/BenchmarkTest02361.java deleted file mode 100644 index 9b859c76428100c028664d1e1bfaf7a51780c5b8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02361.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02361") -public class BenchmarkTest02361 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02361")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02362.java b/OWASP DATASET CLEANED/BenchmarkTest02362.java deleted file mode 100644 index e577df2c58b9def58fd774e9b3fc73b4589cc96c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02362.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02362") -public class BenchmarkTest02362 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02362")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02363.java b/OWASP DATASET CLEANED/BenchmarkTest02363.java deleted file mode 100644 index f377f235544e6ef12b0fc62601b8d58827b16d4e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02363.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02363") -public class BenchmarkTest02363 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02363")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a21456 = param; // assign - StringBuilder b21456 = new StringBuilder(a21456); // stick in stringbuilder - b21456.append(" SafeStuff"); // append some safe content - b21456.replace( - b21456.length() - "Chars".length(), - b21456.length(), - "Chars"); // replace some of the end content - java.util.HashMap map21456 = new java.util.HashMap(); - map21456.put("key21456", b21456.toString()); // put in a collection - String c21456 = (String) map21456.get("key21456"); // get it back out - String d21456 = c21456.substring(0, c21456.length() - 1); // extract most of it - String e21456 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d21456.getBytes()))); // B64 encode and decode it - String f21456 = e21456.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g21456 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g21456); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02364.java b/OWASP DATASET CLEANED/BenchmarkTest02364.java deleted file mode 100644 index 7d20f7c835598403b527c3d5738a2f7205e693d3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02364.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02364") -public class BenchmarkTest02364 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02364")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02365.java b/OWASP DATASET CLEANED/BenchmarkTest02365.java deleted file mode 100644 index 904701a2e6f40e75474934003b2691134315544c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02365.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02365") -public class BenchmarkTest02365 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02365")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02366.java b/OWASP DATASET CLEANED/BenchmarkTest02366.java deleted file mode 100644 index 5e1715ab4dba8519ad6047b6d9d6e14277c0e4cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02366.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02366") -public class BenchmarkTest02366 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02366")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02367.java b/OWASP DATASET CLEANED/BenchmarkTest02367.java deleted file mode 100644 index 3cf526b435d159334bf51e8bbed425ad0fb82fd9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02367.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02367") -public class BenchmarkTest02367 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02367")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a41891 = param; // assign - StringBuilder b41891 = new StringBuilder(a41891); // stick in stringbuilder - b41891.append(" SafeStuff"); // append some safe content - b41891.replace( - b41891.length() - "Chars".length(), - b41891.length(), - "Chars"); // replace some of the end content - java.util.HashMap map41891 = new java.util.HashMap(); - map41891.put("key41891", b41891.toString()); // put in a collection - String c41891 = (String) map41891.get("key41891"); // get it back out - String d41891 = c41891.substring(0, c41891.length() - 1); // extract most of it - String e41891 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d41891.getBytes()))); // B64 encode and decode it - String f41891 = e41891.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g41891 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g41891); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02368.java b/OWASP DATASET CLEANED/BenchmarkTest02368.java deleted file mode 100644 index 2a33327b133d14cb0bf338189b59f4c73b5fb220..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02368.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02368") -public class BenchmarkTest02368 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02368")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02369.java b/OWASP DATASET CLEANED/BenchmarkTest02369.java deleted file mode 100644 index 982b944920b7f320256db8699a4a9b8322c90042..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02369.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02369") -public class BenchmarkTest02369 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02369")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02370.java b/OWASP DATASET CLEANED/BenchmarkTest02370.java deleted file mode 100644 index 7dea340aacd227f3e658ce33f3c26e9545f4417a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02370.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest02370") -public class BenchmarkTest02370 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String param = ""; - boolean flag = true; - java.util.Enumeration names = request.getParameterNames(); - while (names.hasMoreElements() && flag) { - String name = (String) names.nextElement(); - String[] values = request.getParameterValues(name); - if (values != null) { - for (int i = 0; i < values.length && flag; i++) { - String value = values[i]; - if (value.equals("BenchmarkTest02370")) { - param = name; - flag = false; - } - } - } - } - - String bar = doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - org.w3c.dom.NodeList nodeList = - (org.w3c.dom.NodeList) - xp.compile(expression) - .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET); - - response.getWriter().println("Your query results are:
"); - - for (int i = 0; i < nodeList.getLength(); i++) { - org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i); - response.getWriter().println(value.getTextContent() + "
"); - } - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02371.java b/OWASP DATASET CLEANED/BenchmarkTest02371.java deleted file mode 100644 index d5e74f610e4a6012d6bee59d373a7deebb680134..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02371.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02371") -public class BenchmarkTest02371 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02371"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02372.java b/OWASP DATASET CLEANED/BenchmarkTest02372.java deleted file mode 100644 index 611abe66ef3c3f3bb0253778950b273c57c27ae5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02372.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02372") -public class BenchmarkTest02372 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02372"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = org.owasp.benchmark.helpers.Utils.getCipher(); - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02373.java b/OWASP DATASET CLEANED/BenchmarkTest02373.java deleted file mode 100644 index b293f741ab771843bde6fd3affee00a7074a4b10..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02373.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02373") -public class BenchmarkTest02373 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02373"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02374.java b/OWASP DATASET CLEANED/BenchmarkTest02374.java deleted file mode 100644 index 172b078ed86818a3e9c18ed6772e30d70fc0a507..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02374.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02374") -public class BenchmarkTest02374 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02374"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02375.java b/OWASP DATASET CLEANED/BenchmarkTest02375.java deleted file mode 100644 index ccf521d36fbb6e0f004e217bb5f947d455410ba1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02375.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02375") -public class BenchmarkTest02375 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02375"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02376.java b/OWASP DATASET CLEANED/BenchmarkTest02376.java deleted file mode 100644 index c8ae44ef014bc36d978dcc8ec7b8193e9efb8159..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02376.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02376") -public class BenchmarkTest02376 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02376"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02377.java b/OWASP DATASET CLEANED/BenchmarkTest02377.java deleted file mode 100644 index af07ebd06da6e180c6b828dca73fe931bc7c2564..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02377.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02377") -public class BenchmarkTest02377 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02377"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02378.java b/OWASP DATASET CLEANED/BenchmarkTest02378.java deleted file mode 100644 index 2e5edc4a2e2657c245dd6f34686baa7eb6d017e7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02378.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02378") -public class BenchmarkTest02378 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02378"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02379.java b/OWASP DATASET CLEANED/BenchmarkTest02379.java deleted file mode 100644 index d5452023cc9eb42c2a0f0fd9b70f1f866f868dc0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02379.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02379") -public class BenchmarkTest02379 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02379"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file", - null, - startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', java.io.File.separatorChar) - .replace(' ', '_') - + bar, - null, - null); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02380.java b/OWASP DATASET CLEANED/BenchmarkTest02380.java deleted file mode 100644 index c4662b525f85cb6d3f866893088dc15f5d6851db..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02380.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02380") -public class BenchmarkTest02380 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02380"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName)); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a76789 = param; // assign - StringBuilder b76789 = new StringBuilder(a76789); // stick in stringbuilder - b76789.append(" SafeStuff"); // append some safe content - b76789.replace( - b76789.length() - "Chars".length(), - b76789.length(), - "Chars"); // replace some of the end content - java.util.HashMap map76789 = new java.util.HashMap(); - map76789.put("key76789", b76789.toString()); // put in a collection - String c76789 = (String) map76789.get("key76789"); // get it back out - String d76789 = c76789.substring(0, c76789.length() - 1); // extract most of it - String e76789 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d76789.getBytes()))); // B64 encode and decode it - String f76789 = e76789.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g76789 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g76789); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02381.java b/OWASP DATASET CLEANED/BenchmarkTest02381.java deleted file mode 100644 index 3f57c2a55e9399834272fbeea757e881a308a859..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02381.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02381") -public class BenchmarkTest02381 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02381"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map75774 = new java.util.HashMap(); - map75774.put("keyA-75774", "a_Value"); // put some stuff in the collection - map75774.put("keyB-75774", param); // put it in a collection - map75774.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map75774.get("keyB-75774"); // get it back out - bar = (String) map75774.get("keyA-75774"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02382.java b/OWASP DATASET CLEANED/BenchmarkTest02382.java deleted file mode 100644 index 947a0e631a6650ef44b5c76ad65824d7b2d2f07b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02382.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02382") -public class BenchmarkTest02382 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02382"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02383.java b/OWASP DATASET CLEANED/BenchmarkTest02383.java deleted file mode 100644 index 0a13dee9282e25712ac6d33316ecec0442b409e0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02383.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02383") -public class BenchmarkTest02383 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02383"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map53518 = new java.util.HashMap(); - map53518.put("keyA-53518", "a-Value"); // put some stuff in the collection - map53518.put("keyB-53518", param); // put it in a collection - map53518.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map53518.get("keyB-53518"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02384.java b/OWASP DATASET CLEANED/BenchmarkTest02384.java deleted file mode 100644 index d6740554c56aafc24fa53945af74b2e69a4199e4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02384.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02384") -public class BenchmarkTest02384 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02384"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02385.java b/OWASP DATASET CLEANED/BenchmarkTest02385.java deleted file mode 100644 index 5ab784779dc3790bd2da167669d723caa3eb6b69..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02385.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02385") -public class BenchmarkTest02385 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02385"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02386.java b/OWASP DATASET CLEANED/BenchmarkTest02386.java deleted file mode 100644 index c315f87797b60d8cb808e64e697f664119b3e816..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02386.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02386") -public class BenchmarkTest02386 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02386"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02387.java b/OWASP DATASET CLEANED/BenchmarkTest02387.java deleted file mode 100644 index 2f2a6c2e561c5477f2c240e4c872af75a453c426..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02387.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02387") -public class BenchmarkTest02387 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02387"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map70399 = new java.util.HashMap(); - map70399.put("keyA-70399", "a-Value"); // put some stuff in the collection - map70399.put("keyB-70399", param); // put it in a collection - map70399.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map70399.get("keyB-70399"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02388.java b/OWASP DATASET CLEANED/BenchmarkTest02388.java deleted file mode 100644 index 51d1b7229562668716306b158861bd6802595182..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02388.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02388") -public class BenchmarkTest02388 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02388"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map94322 = new java.util.HashMap(); - map94322.put("keyA-94322", "a_Value"); // put some stuff in the collection - map94322.put("keyB-94322", param); // put it in a collection - map94322.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map94322.get("keyB-94322"); // get it back out - bar = (String) map94322.get("keyA-94322"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02389.java b/OWASP DATASET CLEANED/BenchmarkTest02389.java deleted file mode 100644 index 2d90f6fd87172e11c1ab6706a382bfa0d221e985..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02389.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02389") -public class BenchmarkTest02389 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02389"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02390.java b/OWASP DATASET CLEANED/BenchmarkTest02390.java deleted file mode 100644 index 92d3aecdadf3ed610dc902f54cfb043a61b07184..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02390.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02390") -public class BenchmarkTest02390 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02390"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a73202 = param; // assign - StringBuilder b73202 = new StringBuilder(a73202); // stick in stringbuilder - b73202.append(" SafeStuff"); // append some safe content - b73202.replace( - b73202.length() - "Chars".length(), - b73202.length(), - "Chars"); // replace some of the end content - java.util.HashMap map73202 = new java.util.HashMap(); - map73202.put("key73202", b73202.toString()); // put in a collection - String c73202 = (String) map73202.get("key73202"); // get it back out - String d73202 = c73202.substring(0, c73202.length() - 1); // extract most of it - String e73202 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d73202.getBytes()))); // B64 encode and decode it - String f73202 = e73202.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g73202 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g73202); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02391.java b/OWASP DATASET CLEANED/BenchmarkTest02391.java deleted file mode 100644 index 2ac820b0a4e5ea875fcf58231de3311d70809b76..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02391.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02391") -public class BenchmarkTest02391 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02391"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02392.java b/OWASP DATASET CLEANED/BenchmarkTest02392.java deleted file mode 100644 index 2adc765cb72a657e637597873f9e516d81ef59e5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02392.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02392") -public class BenchmarkTest02392 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02392"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02393.java b/OWASP DATASET CLEANED/BenchmarkTest02393.java deleted file mode 100644 index 874f0e5cf46b8221166eca0daed66d29fa54de01..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02393.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02393") -public class BenchmarkTest02393 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02393"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a24492 = param; // assign - StringBuilder b24492 = new StringBuilder(a24492); // stick in stringbuilder - b24492.append(" SafeStuff"); // append some safe content - b24492.replace( - b24492.length() - "Chars".length(), - b24492.length(), - "Chars"); // replace some of the end content - java.util.HashMap map24492 = new java.util.HashMap(); - map24492.put("key24492", b24492.toString()); // put in a collection - String c24492 = (String) map24492.get("key24492"); // get it back out - String d24492 = c24492.substring(0, c24492.length() - 1); // extract most of it - String e24492 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d24492.getBytes()))); // B64 encode and decode it - String f24492 = e24492.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g24492 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g24492); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02394.java b/OWASP DATASET CLEANED/BenchmarkTest02394.java deleted file mode 100644 index 8edd9c86276f93c6bf543ae60824d4bda62bb6de..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02394.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02394") -public class BenchmarkTest02394 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02394"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02395.java b/OWASP DATASET CLEANED/BenchmarkTest02395.java deleted file mode 100644 index affa0d12fc5cbf2e26f88a55a35a5af6c3e4600e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02395.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02395") -public class BenchmarkTest02395 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02395"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().format("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02396.java b/OWASP DATASET CLEANED/BenchmarkTest02396.java deleted file mode 100644 index b50959dec52a6e00998b4da3a3bb478e41f9340b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02396.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02396") -public class BenchmarkTest02396 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02396"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a53479 = param; // assign - StringBuilder b53479 = new StringBuilder(a53479); // stick in stringbuilder - b53479.append(" SafeStuff"); // append some safe content - b53479.replace( - b53479.length() - "Chars".length(), - b53479.length(), - "Chars"); // replace some of the end content - java.util.HashMap map53479 = new java.util.HashMap(); - map53479.put("key53479", b53479.toString()); // put in a collection - String c53479 = (String) map53479.get("key53479"); // get it back out - String d53479 = c53479.substring(0, c53479.length() - 1); // extract most of it - String e53479 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d53479.getBytes()))); // B64 encode and decode it - String f53479 = e53479.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f53479); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02397.java b/OWASP DATASET CLEANED/BenchmarkTest02397.java deleted file mode 100644 index c558e7e25968637aab7c96b0e0b4a0804b05f3ba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02397.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02397") -public class BenchmarkTest02397 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02397"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02398.java b/OWASP DATASET CLEANED/BenchmarkTest02398.java deleted file mode 100644 index b537ab035ab64f838077656db88be6a5b19ba0fb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02398.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02398") -public class BenchmarkTest02398 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02398"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02399.java b/OWASP DATASET CLEANED/BenchmarkTest02399.java deleted file mode 100644 index f5a9979585a5d7a0fb4a8fbe787bc045e071b060..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02399.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02399") -public class BenchmarkTest02399 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02399"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02400.java b/OWASP DATASET CLEANED/BenchmarkTest02400.java deleted file mode 100644 index c7b079da5fb23caf71d78e44390bcfc4b40c5568..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02400.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02400") -public class BenchmarkTest02400 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02400"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02401.java b/OWASP DATASET CLEANED/BenchmarkTest02401.java deleted file mode 100644 index 831cb5bf728636419a682c10eb744341835c6eeb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02401.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02401") -public class BenchmarkTest02401 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02401"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02402.java b/OWASP DATASET CLEANED/BenchmarkTest02402.java deleted file mode 100644 index 08aef2fb3e08fda55dd8fb425d7a06af81a7b50c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02402.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02402") -public class BenchmarkTest02402 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02402"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map55396 = new java.util.HashMap(); - map55396.put("keyA-55396", "a-Value"); // put some stuff in the collection - map55396.put("keyB-55396", param); // put it in a collection - map55396.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map55396.get("keyB-55396"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02403.java b/OWASP DATASET CLEANED/BenchmarkTest02403.java deleted file mode 100644 index c3ce2a02ffe5a5fd4d4367490ec7001460113b9e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02403.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02403") -public class BenchmarkTest02403 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02403"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a34270 = param; // assign - StringBuilder b34270 = new StringBuilder(a34270); // stick in stringbuilder - b34270.append(" SafeStuff"); // append some safe content - b34270.replace( - b34270.length() - "Chars".length(), - b34270.length(), - "Chars"); // replace some of the end content - java.util.HashMap map34270 = new java.util.HashMap(); - map34270.put("key34270", b34270.toString()); // put in a collection - String c34270 = (String) map34270.get("key34270"); // get it back out - String d34270 = c34270.substring(0, c34270.length() - 1); // extract most of it - String e34270 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d34270.getBytes()))); // B64 encode and decode it - String f34270 = e34270.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f34270); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02404.java b/OWASP DATASET CLEANED/BenchmarkTest02404.java deleted file mode 100644 index 3904be4f05493638912369ae122a21f106ef1ff2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02404.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02404") -public class BenchmarkTest02404 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02404"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02405.java b/OWASP DATASET CLEANED/BenchmarkTest02405.java deleted file mode 100644 index e9b1d53b474ed07056dfcfb8a4fac953af31b27d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02405.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02405") -public class BenchmarkTest02405 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02405"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02406.java b/OWASP DATASET CLEANED/BenchmarkTest02406.java deleted file mode 100644 index 3bc41302eb8d6169fc5198b77df6d28bee9dffcd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02406.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02406") -public class BenchmarkTest02406 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02406"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02407.java b/OWASP DATASET CLEANED/BenchmarkTest02407.java deleted file mode 100644 index 729228371ac271bb03833249e3cf3f95cf060b2b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02407.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02407") -public class BenchmarkTest02407 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02407"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz58438 = new StringBuilder(param); - bar = sbxyz58438.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02408.java b/OWASP DATASET CLEANED/BenchmarkTest02408.java deleted file mode 100644 index 85a876205c7a25dcd762fdc4263901c25524ab68..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02408.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02408") -public class BenchmarkTest02408 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02408"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a67594 = param; // assign - StringBuilder b67594 = new StringBuilder(a67594); // stick in stringbuilder - b67594.append(" SafeStuff"); // append some safe content - b67594.replace( - b67594.length() - "Chars".length(), - b67594.length(), - "Chars"); // replace some of the end content - java.util.HashMap map67594 = new java.util.HashMap(); - map67594.put("key67594", b67594.toString()); // put in a collection - String c67594 = (String) map67594.get("key67594"); // get it back out - String d67594 = c67594.substring(0, c67594.length() - 1); // extract most of it - String e67594 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d67594.getBytes()))); // B64 encode and decode it - String f67594 = e67594.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g67594 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g67594); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02409.java b/OWASP DATASET CLEANED/BenchmarkTest02409.java deleted file mode 100644 index 0cd3615559c194dc8f7f4ec9d1509bb92b377dc1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02409.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02409") -public class BenchmarkTest02409 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02409"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02410.java b/OWASP DATASET CLEANED/BenchmarkTest02410.java deleted file mode 100644 index ec5cb4e1ddf0409984f6a37cad2f8e1f73fc9895..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02410.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02410") -public class BenchmarkTest02410 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02410"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz69687 = new StringBuilder(param); - String bar = sbxyz69687.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02411.java b/OWASP DATASET CLEANED/BenchmarkTest02411.java deleted file mode 100644 index 8237d87e19c8873890fbba3848ea0c9551fa246f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02411.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02411") -public class BenchmarkTest02411 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02411"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02412.java b/OWASP DATASET CLEANED/BenchmarkTest02412.java deleted file mode 100644 index 355b3d0994c67539fb06e0b4cc8941528d44ba96..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02412.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02412") -public class BenchmarkTest02412 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02412"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02413.java b/OWASP DATASET CLEANED/BenchmarkTest02413.java deleted file mode 100644 index 24068999bc25f0aaa0f522f59ac24d184bf9f98b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02413.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02413") -public class BenchmarkTest02413 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02413"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02414.java b/OWASP DATASET CLEANED/BenchmarkTest02414.java deleted file mode 100644 index ac37a716a8ea578abc915d1d061a242bb093495a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02414.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02414") -public class BenchmarkTest02414 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02414"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02415.java b/OWASP DATASET CLEANED/BenchmarkTest02415.java deleted file mode 100644 index 69446e386a3b3dad071ca0c85ab533a1c34c9313..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02415.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02415") -public class BenchmarkTest02415 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02415"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02416.java b/OWASP DATASET CLEANED/BenchmarkTest02416.java deleted file mode 100644 index dc15c5f2860d65eed93092362db65ce4adb93880..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02416.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02416") -public class BenchmarkTest02416 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02416"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map59148 = new java.util.HashMap(); - map59148.put("keyA-59148", "a_Value"); // put some stuff in the collection - map59148.put("keyB-59148", param); // put it in a collection - map59148.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map59148.get("keyB-59148"); // get it back out - bar = (String) map59148.get("keyA-59148"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02417.java b/OWASP DATASET CLEANED/BenchmarkTest02417.java deleted file mode 100644 index 6d48908255516d524d69a2cce001b49285115413..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02417.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02417") -public class BenchmarkTest02417 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02417"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02418.java b/OWASP DATASET CLEANED/BenchmarkTest02418.java deleted file mode 100644 index 9bd7566d4f61d8e82d4e117e701cc3dc45fa4450..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02418.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02418") -public class BenchmarkTest02418 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02418"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02419.java b/OWASP DATASET CLEANED/BenchmarkTest02419.java deleted file mode 100644 index 72d9742e5ea5e2a908917e3c48c1ff45f24f2c0d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02419.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02419") -public class BenchmarkTest02419 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02419"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a8935 = param; // assign - StringBuilder b8935 = new StringBuilder(a8935); // stick in stringbuilder - b8935.append(" SafeStuff"); // append some safe content - b8935.replace( - b8935.length() - "Chars".length(), - b8935.length(), - "Chars"); // replace some of the end content - java.util.HashMap map8935 = new java.util.HashMap(); - map8935.put("key8935", b8935.toString()); // put in a collection - String c8935 = (String) map8935.get("key8935"); // get it back out - String d8935 = c8935.substring(0, c8935.length() - 1); // extract most of it - String e8935 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d8935.getBytes()))); // B64 encode and decode it - String f8935 = e8935.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g8935 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g8935); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02420.java b/OWASP DATASET CLEANED/BenchmarkTest02420.java deleted file mode 100644 index 3fdffedda3ab6b917ba231a2ed3a3d0163703139..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02420.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02420") -public class BenchmarkTest02420 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02420"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02421.java b/OWASP DATASET CLEANED/BenchmarkTest02421.java deleted file mode 100644 index 403c7b37775a2fa60abca68f21caef0f9313ea92..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02421.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02421") -public class BenchmarkTest02421 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02421"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map85191 = new java.util.HashMap(); - map85191.put("keyA-85191", "a_Value"); // put some stuff in the collection - map85191.put("keyB-85191", param); // put it in a collection - map85191.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map85191.get("keyB-85191"); // get it back out - bar = (String) map85191.get("keyA-85191"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02422.java b/OWASP DATASET CLEANED/BenchmarkTest02422.java deleted file mode 100644 index e3480def279fae08743342ab16f8c52ef665b1f3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02422.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02422") -public class BenchmarkTest02422 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02422"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02423.java b/OWASP DATASET CLEANED/BenchmarkTest02423.java deleted file mode 100644 index 3276b07ebf88d8e994607fdf34df337c292d9974..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02423.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02423") -public class BenchmarkTest02423 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02423"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - int randNumber = new java.util.Random().nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "Inga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a24134 = param; // assign - StringBuilder b24134 = new StringBuilder(a24134); // stick in stringbuilder - b24134.append(" SafeStuff"); // append some safe content - b24134.replace( - b24134.length() - "Chars".length(), - b24134.length(), - "Chars"); // replace some of the end content - java.util.HashMap map24134 = new java.util.HashMap(); - map24134.put("key24134", b24134.toString()); // put in a collection - String c24134 = (String) map24134.get("key24134"); // get it back out - String d24134 = c24134.substring(0, c24134.length() - 1); // extract most of it - String e24134 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d24134.getBytes()))); // B64 encode and decode it - String f24134 = e24134.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f24134); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02424.java b/OWASP DATASET CLEANED/BenchmarkTest02424.java deleted file mode 100644 index 387c62b178cd6dfdead6e92a92227de4757d6614..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02424.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02424") -public class BenchmarkTest02424 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02424"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02425.java b/OWASP DATASET CLEANED/BenchmarkTest02425.java deleted file mode 100644 index 13cbacc2dfde70b1aa3d2e7fb6969edbf8815e84..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02425.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02425") -public class BenchmarkTest02425 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02425"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02426.java b/OWASP DATASET CLEANED/BenchmarkTest02426.java deleted file mode 100644 index 42b3b1c7c4ef4cd2d289b2adfa990f71cb916ce5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02426.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02426") -public class BenchmarkTest02426 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02426"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02427.java b/OWASP DATASET CLEANED/BenchmarkTest02427.java deleted file mode 100644 index 185efe965422091c0b7ea463d22ecfdf39de9902..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02427.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02427") -public class BenchmarkTest02427 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02427"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02428.java b/OWASP DATASET CLEANED/BenchmarkTest02428.java deleted file mode 100644 index 93fd5f08ebcd4f149b0c3c4bc6e9ab9898a89b16..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02428.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02428") -public class BenchmarkTest02428 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02428"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd + bar); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map52815 = new java.util.HashMap(); - map52815.put("keyA-52815", "a_Value"); // put some stuff in the collection - map52815.put("keyB-52815", param); // put it in a collection - map52815.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map52815.get("keyB-52815"); // get it back out - bar = (String) map52815.get("keyA-52815"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02429.java b/OWASP DATASET CLEANED/BenchmarkTest02429.java deleted file mode 100644 index df56e600c0d6052ca3bc45dabcab0f505ab18829..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02429.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02429") -public class BenchmarkTest02429 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02429"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo"); - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ping -c1 "); - args = new String[] {a1, a2, cmd + bar}; - } - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02430.java b/OWASP DATASET CLEANED/BenchmarkTest02430.java deleted file mode 100644 index 2ac6ae6a57d07d6b2b73d5970e5d2d062f0feeb5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02430.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02430") -public class BenchmarkTest02430 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02430"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02431.java b/OWASP DATASET CLEANED/BenchmarkTest02431.java deleted file mode 100644 index 89de45a3f5767f3e7c9463b6ac07607f5096731a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02431.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02431") -public class BenchmarkTest02431 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02431"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map58889 = new java.util.HashMap(); - map58889.put("keyA-58889", "a-Value"); // put some stuff in the collection - map58889.put("keyB-58889", param); // put it in a collection - map58889.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map58889.get("keyB-58889"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02432.java b/OWASP DATASET CLEANED/BenchmarkTest02432.java deleted file mode 100644 index 164a63ecd3bc389c2823e5ed292543a3f2ee5ccd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02432.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02432") -public class BenchmarkTest02432 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02432"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map15850 = new java.util.HashMap(); - map15850.put("keyA-15850", "a-Value"); // put some stuff in the collection - map15850.put("keyB-15850", param); // put it in a collection - map15850.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map15850.get("keyB-15850"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02433.java b/OWASP DATASET CLEANED/BenchmarkTest02433.java deleted file mode 100644 index d2e0fdd3117986b3926bcaea8683dd804f0ba5ba..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02433.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02433") -public class BenchmarkTest02433 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02433"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02434.java b/OWASP DATASET CLEANED/BenchmarkTest02434.java deleted file mode 100644 index eab0d5b7ee87bc56f2c1a0784580074b4f9f357f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02434.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02434") -public class BenchmarkTest02434 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02434"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map29737 = new java.util.HashMap(); - map29737.put("keyA-29737", "a-Value"); // put some stuff in the collection - map29737.put("keyB-29737", param); // put it in a collection - map29737.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map29737.get("keyB-29737"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02435.java b/OWASP DATASET CLEANED/BenchmarkTest02435.java deleted file mode 100644 index 0b1d2d975393593d013f0f85c14b4ae3faf0e110..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02435.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02435") -public class BenchmarkTest02435 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02435"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02436.java b/OWASP DATASET CLEANED/BenchmarkTest02436.java deleted file mode 100644 index 714421b1b80c932c94a464ec1323f0954fdc25b7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02436.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02436") -public class BenchmarkTest02436 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02436"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02437.java b/OWASP DATASET CLEANED/BenchmarkTest02437.java deleted file mode 100644 index 45bd3e5af4cc754fc31d2117b259b62e2af5b10b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02437.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02437") -public class BenchmarkTest02437 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02437"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02438.java b/OWASP DATASET CLEANED/BenchmarkTest02438.java deleted file mode 100644 index 4f0c97e2ff97279a86d6a8b19e4a8b8c0d9e260d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02438.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02438") -public class BenchmarkTest02438 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02438"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02439.java b/OWASP DATASET CLEANED/BenchmarkTest02439.java deleted file mode 100644 index f07bbc5e93495f0a34db8e338637f3133d7d6695..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02439.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02439") -public class BenchmarkTest02439 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02439"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02440.java b/OWASP DATASET CLEANED/BenchmarkTest02440.java deleted file mode 100644 index 6844a49822e2449ee23493b349e06f467e4e3eb9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02440.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02440") -public class BenchmarkTest02440 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02440"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map85251 = new java.util.HashMap(); - map85251.put("keyA-85251", "a_Value"); // put some stuff in the collection - map85251.put("keyB-85251", param); // put it in a collection - map85251.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map85251.get("keyB-85251"); // get it back out - bar = (String) map85251.get("keyA-85251"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02441.java b/OWASP DATASET CLEANED/BenchmarkTest02441.java deleted file mode 100644 index 8b8933e5fd607f83f344cf1532b327626972d05e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02441.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02441") -public class BenchmarkTest02441 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02441"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02442.java b/OWASP DATASET CLEANED/BenchmarkTest02442.java deleted file mode 100644 index 996ba59336c2613bbf20cf4add83526a1812e56a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02442.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02442") -public class BenchmarkTest02442 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02442"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz18041 = new StringBuilder(param); - bar = sbxyz18041.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02443.java b/OWASP DATASET CLEANED/BenchmarkTest02443.java deleted file mode 100644 index eb37b8aab3bef7fc20a4d5c5137ed0be8cba148b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02443.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02443") -public class BenchmarkTest02443 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02443"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02444.java b/OWASP DATASET CLEANED/BenchmarkTest02444.java deleted file mode 100644 index 26e9d43edeabf408b32c788afd9eb2fa40d28af7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02444.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02444") -public class BenchmarkTest02444 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02444"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02445.java b/OWASP DATASET CLEANED/BenchmarkTest02445.java deleted file mode 100644 index c446715a0f50f05398a2c2bcfec16013423df391..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02445.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02445") -public class BenchmarkTest02445 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02445"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02446.java b/OWASP DATASET CLEANED/BenchmarkTest02446.java deleted file mode 100644 index a4556a61ea1ce095da4caa2467f9e1c2c3dd5606..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02446.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02446") -public class BenchmarkTest02446 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02446"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02447.java b/OWASP DATASET CLEANED/BenchmarkTest02447.java deleted file mode 100644 index 7897f687432bc09464ed0444d60d296b6d7181fe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02447.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02447") -public class BenchmarkTest02447 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02447"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02448.java b/OWASP DATASET CLEANED/BenchmarkTest02448.java deleted file mode 100644 index 22e33c78d77e9921f01672e5da832b84bc972aa8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02448.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02448") -public class BenchmarkTest02448 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02448"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02449.java b/OWASP DATASET CLEANED/BenchmarkTest02449.java deleted file mode 100644 index c2e222c3026d709784add23e48c41aef9b5a435a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02449.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02449") -public class BenchmarkTest02449 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02449"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02450.java b/OWASP DATASET CLEANED/BenchmarkTest02450.java deleted file mode 100644 index dfe1e414bacbb6cc458ed1f028bf71fb8f2d26b2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02450.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02450") -public class BenchmarkTest02450 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02450"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02451.java b/OWASP DATASET CLEANED/BenchmarkTest02451.java deleted file mode 100644 index 40b3946c5b6a2431ac69e519a1e4ce15d213597c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02451.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02451") -public class BenchmarkTest02451 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02451"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02452.java b/OWASP DATASET CLEANED/BenchmarkTest02452.java deleted file mode 100644 index 5aab2d2441c1046db91cea162c2561a57318a76f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02452.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02452") -public class BenchmarkTest02452 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02452"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a91263 = param; // assign - StringBuilder b91263 = new StringBuilder(a91263); // stick in stringbuilder - b91263.append(" SafeStuff"); // append some safe content - b91263.replace( - b91263.length() - "Chars".length(), - b91263.length(), - "Chars"); // replace some of the end content - java.util.HashMap map91263 = new java.util.HashMap(); - map91263.put("key91263", b91263.toString()); // put in a collection - String c91263 = (String) map91263.get("key91263"); // get it back out - String d91263 = c91263.substring(0, c91263.length() - 1); // extract most of it - String e91263 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d91263.getBytes()))); // B64 encode and decode it - String f91263 = e91263.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g91263 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g91263); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02453.java b/OWASP DATASET CLEANED/BenchmarkTest02453.java deleted file mode 100644 index cb34a8382e019405363813e60a4071194c35608e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02453.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02453") -public class BenchmarkTest02453 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02453"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02454.java b/OWASP DATASET CLEANED/BenchmarkTest02454.java deleted file mode 100644 index 69d1bbba6c1e283381d44a2d656ccb63c3dea321..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02454.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02454") -public class BenchmarkTest02454 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02454"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02455.java b/OWASP DATASET CLEANED/BenchmarkTest02455.java deleted file mode 100644 index bcdb016a48090d35fb9d0b0cd5416c78a1163a08..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02455.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02455") -public class BenchmarkTest02455 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02455"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02456.java b/OWASP DATASET CLEANED/BenchmarkTest02456.java deleted file mode 100644 index bfdbb132da1a6433fb9220aec68f219b8d599b34..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02456.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02456") -public class BenchmarkTest02456 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02456"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02457.java b/OWASP DATASET CLEANED/BenchmarkTest02457.java deleted file mode 100644 index 923a2039f42b442c3bcff197c8afbc03ddbc014b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02457.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xpathi-00/BenchmarkTest02457") -public class BenchmarkTest02457 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheParameter("BenchmarkTest02457"); - if (param == null) param = ""; - - String bar = doSomething(request, param); - - try { - java.io.FileInputStream file = - new java.io.FileInputStream( - org.owasp.benchmark.helpers.Utils.getFileFromClasspath( - "employees.xml", this.getClass().getClassLoader())); - javax.xml.parsers.DocumentBuilderFactory builderFactory = - javax.xml.parsers.DocumentBuilderFactory.newInstance(); - // Prevent XXE - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder(); - org.w3c.dom.Document xmlDocument = builder.parse(file); - javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); - javax.xml.xpath.XPath xp = xpf.newXPath(); - - String expression = "/Employees/Employee[@emplid='" + bar + "']"; - String result = xp.evaluate(expression, xmlDocument); - - response.getWriter().println("Your query results are: " + result + "
"); - - } catch (javax.xml.xpath.XPathExpressionException - | javax.xml.parsers.ParserConfigurationException - | org.xml.sax.SAXException e) { - response.getWriter() - .println( - "Error parsing XPath input: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar) - + "'"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02458.java b/OWASP DATASET CLEANED/BenchmarkTest02458.java deleted file mode 100644 index daf677aac52cfddc922e17434c6499ae3159294c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02458.java +++ /dev/null @@ -1,165 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02458") -public class BenchmarkTest02458 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02458"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02459.java b/OWASP DATASET CLEANED/BenchmarkTest02459.java deleted file mode 100644 index a47a0e79bfdd40c5ea02904a7f9323a10348f7e1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02459.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02459") -public class BenchmarkTest02459 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02459"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map56716 = new java.util.HashMap(); - map56716.put("keyA-56716", "a-Value"); // put some stuff in the collection - map56716.put("keyB-56716", param); // put it in a collection - map56716.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map56716.get("keyB-56716"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02460.java b/OWASP DATASET CLEANED/BenchmarkTest02460.java deleted file mode 100644 index b5a0ee5481f8eddfe1a95d5d128d47a1c52ca4a7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02460.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02460") -public class BenchmarkTest02460 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02460"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02461.java b/OWASP DATASET CLEANED/BenchmarkTest02461.java deleted file mode 100644 index d40524db90693bd6f04ed5e3ddb2f525880c3d61..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02461.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02461") -public class BenchmarkTest02461 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02461"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02462.java b/OWASP DATASET CLEANED/BenchmarkTest02462.java deleted file mode 100644 index 6b3984e33ee3eb962bc69f2f1d3940e863dd4fad..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02462.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02462") -public class BenchmarkTest02462 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02462"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02463.java b/OWASP DATASET CLEANED/BenchmarkTest02463.java deleted file mode 100644 index f2f0b07cac0d874046c91f09166785ff81636c48..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02463.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02463") -public class BenchmarkTest02463 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02463"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR, bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02464.java b/OWASP DATASET CLEANED/BenchmarkTest02464.java deleted file mode 100644 index ca7d8c33e1c8e25a791974e85fd05bb190167c76..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02464.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02464") -public class BenchmarkTest02464 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02464"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02465.java b/OWASP DATASET CLEANED/BenchmarkTest02465.java deleted file mode 100644 index 5aa56319d400fc10934cbeb8e4713d4174f8aa5e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02465.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02465") -public class BenchmarkTest02465 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02465"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02466.java b/OWASP DATASET CLEANED/BenchmarkTest02466.java deleted file mode 100644 index 38439237a8df42436b0612ef7f9515836d758e64..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02466.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-02/BenchmarkTest02466") -public class BenchmarkTest02466 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02466"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02467.java b/OWASP DATASET CLEANED/BenchmarkTest02467.java deleted file mode 100644 index 7b2fa26d62431ff59d6ac9f149b424ac4a91a726..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02467.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02467") -public class BenchmarkTest02467 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02467"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a60326 = param; // assign - StringBuilder b60326 = new StringBuilder(a60326); // stick in stringbuilder - b60326.append(" SafeStuff"); // append some safe content - b60326.replace( - b60326.length() - "Chars".length(), - b60326.length(), - "Chars"); // replace some of the end content - java.util.HashMap map60326 = new java.util.HashMap(); - map60326.put("key60326", b60326.toString()); // put in a collection - String c60326 = (String) map60326.get("key60326"); // get it back out - String d60326 = c60326.substring(0, c60326.length() - 1); // extract most of it - String e60326 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d60326.getBytes()))); // B64 encode and decode it - String f60326 = e60326.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g60326 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g60326); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02468.java b/OWASP DATASET CLEANED/BenchmarkTest02468.java deleted file mode 100644 index 9b962010ae94802999e1de31dcc23b29d1f2592f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02468.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02468") -public class BenchmarkTest02468 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02468"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02469.java b/OWASP DATASET CLEANED/BenchmarkTest02469.java deleted file mode 100644 index 11012b92ad7b19a383846d6917d844a9604a7599..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02469.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02469") -public class BenchmarkTest02469 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02469"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02470.java b/OWASP DATASET CLEANED/BenchmarkTest02470.java deleted file mode 100644 index e5321427a04e272d4f6825b39542656327ae561a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02470.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02470") -public class BenchmarkTest02470 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02470"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02471.java b/OWASP DATASET CLEANED/BenchmarkTest02471.java deleted file mode 100644 index 9755a48c3d9be51aab5b1ba1781c077ef03ceb83..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02471.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02471") -public class BenchmarkTest02471 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02471"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02472.java b/OWASP DATASET CLEANED/BenchmarkTest02472.java deleted file mode 100644 index c36b45758740a8fd0c3f7edf4a516105e94b4953..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02472.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02472") -public class BenchmarkTest02472 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02472"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02473.java b/OWASP DATASET CLEANED/BenchmarkTest02473.java deleted file mode 100644 index 059334a5f9e940eda91ad7f49fbf3b06bb1e6855..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02473.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02473") -public class BenchmarkTest02473 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02473"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - double value = java.lang.Math.random(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Doug"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map91880 = new java.util.HashMap(); - map91880.put("keyA-91880", "a-Value"); // put some stuff in the collection - map91880.put("keyB-91880", param); // put it in a collection - map91880.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map91880.get("keyB-91880"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02474.java b/OWASP DATASET CLEANED/BenchmarkTest02474.java deleted file mode 100644 index 93664716d5499b9ab6abf45d4dfbe337b66df288..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02474.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02474") -public class BenchmarkTest02474 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02474"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02475.java b/OWASP DATASET CLEANED/BenchmarkTest02475.java deleted file mode 100644 index 21470f1025f34b83c3604c4070c597914fb1cbe0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02475.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02475") -public class BenchmarkTest02475 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02475"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map43776 = new java.util.HashMap(); - map43776.put("keyA-43776", "a-Value"); // put some stuff in the collection - map43776.put("keyB-43776", param); // put it in a collection - map43776.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map43776.get("keyB-43776"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02476.java b/OWASP DATASET CLEANED/BenchmarkTest02476.java deleted file mode 100644 index 115561b6011cd10067ee30283f9ae799f0b085fa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02476.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02476") -public class BenchmarkTest02476 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02476"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02477.java b/OWASP DATASET CLEANED/BenchmarkTest02477.java deleted file mode 100644 index baff191b4f95c5c0702a2b785c1f3f2f01241666..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02477.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02477") -public class BenchmarkTest02477 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02477"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a40743 = param; // assign - StringBuilder b40743 = new StringBuilder(a40743); // stick in stringbuilder - b40743.append(" SafeStuff"); // append some safe content - b40743.replace( - b40743.length() - "Chars".length(), - b40743.length(), - "Chars"); // replace some of the end content - java.util.HashMap map40743 = new java.util.HashMap(); - map40743.put("key40743", b40743.toString()); // put in a collection - String c40743 = (String) map40743.get("key40743"); // get it back out - String d40743 = c40743.substring(0, c40743.length() - 1); // extract most of it - String e40743 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d40743.getBytes()))); // B64 encode and decode it - String f40743 = e40743.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g40743 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g40743); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02478.java b/OWASP DATASET CLEANED/BenchmarkTest02478.java deleted file mode 100644 index b709c1052c5ef89d64edd6c50c99f104c9a51056..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02478.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02478") -public class BenchmarkTest02478 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02478"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02479.java b/OWASP DATASET CLEANED/BenchmarkTest02479.java deleted file mode 100644 index 6f14288d5d7515f4b9cd2eea793daeff4066f466..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02479.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02479") -public class BenchmarkTest02479 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02479"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02480.java b/OWASP DATASET CLEANED/BenchmarkTest02480.java deleted file mode 100644 index 73b0997ba520501631903b0a3470517bcfdc019d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02480.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02480") -public class BenchmarkTest02480 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02480"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02481.java b/OWASP DATASET CLEANED/BenchmarkTest02481.java deleted file mode 100644 index 0659a20dbc096035f59091b23a3184cd2c14bdc3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02481.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02481") -public class BenchmarkTest02481 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02481"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02482.java b/OWASP DATASET CLEANED/BenchmarkTest02482.java deleted file mode 100644 index fd109e2cf8ed5bf0af37e2558cba495771cfd355..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02482.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02482") -public class BenchmarkTest02482 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02482"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02483.java b/OWASP DATASET CLEANED/BenchmarkTest02483.java deleted file mode 100644 index 1a1ac72911022bc9a5c023d5cb13c94876ebd223..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02483.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02483") -public class BenchmarkTest02483 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02483"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02484.java b/OWASP DATASET CLEANED/BenchmarkTest02484.java deleted file mode 100644 index 355b3e59bd6024ad65ea44dc5ffb0a32244bbe5e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02484.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02484") -public class BenchmarkTest02484 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02484"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map12535 = new java.util.HashMap(); - map12535.put("keyA-12535", "a_Value"); // put some stuff in the collection - map12535.put("keyB-12535", param); // put it in a collection - map12535.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map12535.get("keyB-12535"); // get it back out - bar = (String) map12535.get("keyA-12535"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02485.java b/OWASP DATASET CLEANED/BenchmarkTest02485.java deleted file mode 100644 index a1d628da779dd09a08885b57b9590a0d7e6f6a8c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02485.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02485") -public class BenchmarkTest02485 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02485"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02486.java b/OWASP DATASET CLEANED/BenchmarkTest02486.java deleted file mode 100644 index a6827afca80c617926c47c9f4f770ab131d84d83..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02486.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-04/BenchmarkTest02486") -public class BenchmarkTest02486 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02486"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz61588 = new StringBuilder(param); - bar = sbxyz61588.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02487.java b/OWASP DATASET CLEANED/BenchmarkTest02487.java deleted file mode 100644 index 3549a844f092f1c754dda2698aee09a07a5092fd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02487.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02487") -public class BenchmarkTest02487 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02487"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02488.java b/OWASP DATASET CLEANED/BenchmarkTest02488.java deleted file mode 100644 index 7a1392869f78668ab7b1b39aa5ad54378f1e11da..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02488.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02488") -public class BenchmarkTest02488 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02488"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02489.java b/OWASP DATASET CLEANED/BenchmarkTest02489.java deleted file mode 100644 index 41ea6d3203d985c172dd0ab833896c85d7d03127..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02489.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02489") -public class BenchmarkTest02489 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02489"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02490.java b/OWASP DATASET CLEANED/BenchmarkTest02490.java deleted file mode 100644 index 46d844380a33f315397e0d2343adedc6162d0b49..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02490.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02490") -public class BenchmarkTest02490 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02490"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a28523 = param; // assign - StringBuilder b28523 = new StringBuilder(a28523); // stick in stringbuilder - b28523.append(" SafeStuff"); // append some safe content - b28523.replace( - b28523.length() - "Chars".length(), - b28523.length(), - "Chars"); // replace some of the end content - java.util.HashMap map28523 = new java.util.HashMap(); - map28523.put("key28523", b28523.toString()); // put in a collection - String c28523 = (String) map28523.get("key28523"); // get it back out - String d28523 = c28523.substring(0, c28523.length() - 1); // extract most of it - String e28523 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d28523.getBytes()))); // B64 encode and decode it - String f28523 = e28523.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g28523 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g28523); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02491.java b/OWASP DATASET CLEANED/BenchmarkTest02491.java deleted file mode 100644 index 1dc16c4135379d506db56153a0b20a701dc7dd79..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02491.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02491") -public class BenchmarkTest02491 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02491"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a17852 = param; // assign - StringBuilder b17852 = new StringBuilder(a17852); // stick in stringbuilder - b17852.append(" SafeStuff"); // append some safe content - b17852.replace( - b17852.length() - "Chars".length(), - b17852.length(), - "Chars"); // replace some of the end content - java.util.HashMap map17852 = new java.util.HashMap(); - map17852.put("key17852", b17852.toString()); // put in a collection - String c17852 = (String) map17852.get("key17852"); // get it back out - String d17852 = c17852.substring(0, c17852.length() - 1); // extract most of it - String e17852 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d17852.getBytes()))); // B64 encode and decode it - String f17852 = e17852.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g17852 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g17852); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02492.java b/OWASP DATASET CLEANED/BenchmarkTest02492.java deleted file mode 100644 index f8abe196ea52f68dd4b3096a3c21069bc0922006..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02492.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02492") -public class BenchmarkTest02492 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02492"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02493.java b/OWASP DATASET CLEANED/BenchmarkTest02493.java deleted file mode 100644 index 9b2dba86f5671cf0c72096ea8d295b4b5df806fe..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02493.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02493") -public class BenchmarkTest02493 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02493"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map4720 = new java.util.HashMap(); - map4720.put("keyA-4720", "a-Value"); // put some stuff in the collection - map4720.put("keyB-4720", param); // put it in a collection - map4720.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map4720.get("keyB-4720"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02494.java b/OWASP DATASET CLEANED/BenchmarkTest02494.java deleted file mode 100644 index 2a9decfa7b8ccd27e3401519c855c0596cfa5ffb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02494.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02494") -public class BenchmarkTest02494 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02494"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz57919 = new StringBuilder(param); - bar = sbxyz57919.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02495.java b/OWASP DATASET CLEANED/BenchmarkTest02495.java deleted file mode 100644 index bf6fc7b831a2f689c2793a5af2d427d929c3e8eb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02495.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02495") -public class BenchmarkTest02495 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02495"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar, 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02496.java b/OWASP DATASET CLEANED/BenchmarkTest02496.java deleted file mode 100644 index 63d488edbf2a8e7fd1f2ac65ad5fa399a1b7cb7f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02496.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02496") -public class BenchmarkTest02496 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02496"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02497.java b/OWASP DATASET CLEANED/BenchmarkTest02497.java deleted file mode 100644 index e2a6093a30ca35bf9f479817beef9153a4c1ea30..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02497.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02497") -public class BenchmarkTest02497 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02497"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a40533 = param; // assign - StringBuilder b40533 = new StringBuilder(a40533); // stick in stringbuilder - b40533.append(" SafeStuff"); // append some safe content - b40533.replace( - b40533.length() - "Chars".length(), - b40533.length(), - "Chars"); // replace some of the end content - java.util.HashMap map40533 = new java.util.HashMap(); - map40533.put("key40533", b40533.toString()); // put in a collection - String c40533 = (String) map40533.get("key40533"); // get it back out - String d40533 = c40533.substring(0, c40533.length() - 1); // extract most of it - String e40533 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d40533.getBytes()))); // B64 encode and decode it - String f40533 = e40533.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g40533 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g40533); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02498.java b/OWASP DATASET CLEANED/BenchmarkTest02498.java deleted file mode 100644 index cee7ee4e9d6c439ec36a6aebcd4f61ab751f0247..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02498.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02498") -public class BenchmarkTest02498 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02498"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02499.java b/OWASP DATASET CLEANED/BenchmarkTest02499.java deleted file mode 100644 index 724cbe69501851dafb38d51159207c88c1f849d9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02499.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02499") -public class BenchmarkTest02499 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02499"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02500.java b/OWASP DATASET CLEANED/BenchmarkTest02500.java deleted file mode 100644 index 7da74e90b782474d834ae850827f8660033b9d2c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02500.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02500") -public class BenchmarkTest02500 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02500"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02501.java b/OWASP DATASET CLEANED/BenchmarkTest02501.java deleted file mode 100644 index 876a87278390fbb9e5c67d8052289c12b122e048..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02501.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02501") -public class BenchmarkTest02501 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02501"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02502.java b/OWASP DATASET CLEANED/BenchmarkTest02502.java deleted file mode 100644 index ed35c871bc630d4596ec8420ee099e98beb7d0ae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02502.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02502") -public class BenchmarkTest02502 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02502"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02503.java b/OWASP DATASET CLEANED/BenchmarkTest02503.java deleted file mode 100644 index 2b9348652cbd0395a1fb0c9ba4c44b57365b029b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02503.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02503") -public class BenchmarkTest02503 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02503"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a70407 = param; // assign - StringBuilder b70407 = new StringBuilder(a70407); // stick in stringbuilder - b70407.append(" SafeStuff"); // append some safe content - b70407.replace( - b70407.length() - "Chars".length(), - b70407.length(), - "Chars"); // replace some of the end content - java.util.HashMap map70407 = new java.util.HashMap(); - map70407.put("key70407", b70407.toString()); // put in a collection - String c70407 = (String) map70407.get("key70407"); // get it back out - String d70407 = c70407.substring(0, c70407.length() - 1); // extract most of it - String e70407 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d70407.getBytes()))); // B64 encode and decode it - String f70407 = e70407.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g70407 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g70407); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02504.java b/OWASP DATASET CLEANED/BenchmarkTest02504.java deleted file mode 100644 index 120c10407d2c066b73284f21c245627bb848bd71..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02504.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02504") -public class BenchmarkTest02504 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02504"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02505.java b/OWASP DATASET CLEANED/BenchmarkTest02505.java deleted file mode 100644 index 39321e150a5275e6b4d3c140e3fa05df1c40196a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02505.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02505") -public class BenchmarkTest02505 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02505"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02506.java b/OWASP DATASET CLEANED/BenchmarkTest02506.java deleted file mode 100644 index a6e9ad86f24c18dfcefbe2da5888a08b1b4c9b06..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02506.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02506") -public class BenchmarkTest02506 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02506"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02507.java b/OWASP DATASET CLEANED/BenchmarkTest02507.java deleted file mode 100644 index 7e3a825f8e52db973e006309b2d8d67e779d4a5a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02507.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02507") -public class BenchmarkTest02507 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02507"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02508.java b/OWASP DATASET CLEANED/BenchmarkTest02508.java deleted file mode 100644 index a2ffa81135d3de06f2551ee87feb1b5d4b6be278..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02508.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02508") -public class BenchmarkTest02508 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02508"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02509.java b/OWASP DATASET CLEANED/BenchmarkTest02509.java deleted file mode 100644 index 3affbf2c3e2366585ba49c50ed2321b1dd14326b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02509.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02509") -public class BenchmarkTest02509 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02509"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02510.java b/OWASP DATASET CLEANED/BenchmarkTest02510.java deleted file mode 100644 index 7e577e0a558f2982e18b563bd311f54886613548..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02510.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02510") -public class BenchmarkTest02510 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02510"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a11776 = param; // assign - StringBuilder b11776 = new StringBuilder(a11776); // stick in stringbuilder - b11776.append(" SafeStuff"); // append some safe content - b11776.replace( - b11776.length() - "Chars".length(), - b11776.length(), - "Chars"); // replace some of the end content - java.util.HashMap map11776 = new java.util.HashMap(); - map11776.put("key11776", b11776.toString()); // put in a collection - String c11776 = (String) map11776.get("key11776"); // get it back out - String d11776 = c11776.substring(0, c11776.length() - 1); // extract most of it - String e11776 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d11776.getBytes()))); // B64 encode and decode it - String f11776 = e11776.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g11776 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g11776); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02511.java b/OWASP DATASET CLEANED/BenchmarkTest02511.java deleted file mode 100644 index d6f3130fc7870a75f2c9eede52c8f195fb077373..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02511.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02511") -public class BenchmarkTest02511 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02511"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02512.java b/OWASP DATASET CLEANED/BenchmarkTest02512.java deleted file mode 100644 index e818eeb35e4e3515d278cafa7c9a99adf4ee147b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02512.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02512") -public class BenchmarkTest02512 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02512"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02513.java b/OWASP DATASET CLEANED/BenchmarkTest02513.java deleted file mode 100644 index 7d8b18ade07b47ed077c2d22f9bf2c9255371d5e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02513.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02513") -public class BenchmarkTest02513 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02513"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02514.java b/OWASP DATASET CLEANED/BenchmarkTest02514.java deleted file mode 100644 index 23797c90977b2d2e7d7cb12011dd02b57b7ef97c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02514.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02514") -public class BenchmarkTest02514 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02514"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02515.java b/OWASP DATASET CLEANED/BenchmarkTest02515.java deleted file mode 100644 index c871644899756ac25ada0ce4f2d6276931d2ed48..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02515.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02515") -public class BenchmarkTest02515 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02515"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(cmd, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02516.java b/OWASP DATASET CLEANED/BenchmarkTest02516.java deleted file mode 100644 index 4212852cb77070266d0019732b33a6929a157df8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02516.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-02/BenchmarkTest02516") -public class BenchmarkTest02516 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02516"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map74796 = new java.util.HashMap(); - map74796.put("keyA-74796", "a-Value"); // put some stuff in the collection - map74796.put("keyB-74796", param); // put it in a collection - map74796.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map74796.get("keyB-74796"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02517.java b/OWASP DATASET CLEANED/BenchmarkTest02517.java deleted file mode 100644 index b9dbf494bfd00f0e5c30d9dac63303b1e06b529b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02517.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02517") -public class BenchmarkTest02517 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02517"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02518.java b/OWASP DATASET CLEANED/BenchmarkTest02518.java deleted file mode 100644 index aa6b0ddb66d91b4548c943a2915e3daed28ae7cc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02518.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02518") -public class BenchmarkTest02518 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02518"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02519.java b/OWASP DATASET CLEANED/BenchmarkTest02519.java deleted file mode 100644 index bb508fe9837dfb32cd00f69f5a1c616aa15e8906..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02519.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02519") -public class BenchmarkTest02519 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02519"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz84406 = new StringBuilder(param); - bar = sbxyz84406.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02520.java b/OWASP DATASET CLEANED/BenchmarkTest02520.java deleted file mode 100644 index e166890e4c11db3b57f7bb5bdca9243c9cce023c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02520.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02520") -public class BenchmarkTest02520 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02520"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02521.java b/OWASP DATASET CLEANED/BenchmarkTest02521.java deleted file mode 100644 index f0ac559b1c880b1357c295bd5d75e5aa1706f2bf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02521.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02521") -public class BenchmarkTest02521 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02521"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02522.java b/OWASP DATASET CLEANED/BenchmarkTest02522.java deleted file mode 100644 index 83090046542d4c8e2366dfa26acccf08fd3b2428..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02522.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02522") -public class BenchmarkTest02522 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02522"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02523.java b/OWASP DATASET CLEANED/BenchmarkTest02523.java deleted file mode 100644 index ec7a2d11061c4ce94ac795f7bf560bf37c1f6d4e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02523.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02523") -public class BenchmarkTest02523 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02523"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02524.java b/OWASP DATASET CLEANED/BenchmarkTest02524.java deleted file mode 100644 index 2366f42a3bdb11bafce6d7a3db15fdd7a6e759f9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02524.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02524") -public class BenchmarkTest02524 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02524"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02525.java b/OWASP DATASET CLEANED/BenchmarkTest02525.java deleted file mode 100644 index 8586793c7e0bc8540fa0222fa5a603ae3cbf0167..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02525.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02525") -public class BenchmarkTest02525 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02525"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02526.java b/OWASP DATASET CLEANED/BenchmarkTest02526.java deleted file mode 100644 index 0e126e629e9e15b44be39c1672936660715622c3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02526.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02526") -public class BenchmarkTest02526 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02526"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^) - request.getSession().putValue("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02527.java b/OWASP DATASET CLEANED/BenchmarkTest02527.java deleted file mode 100644 index e17c860febfa8ef7200188b0d198f60149b7c711..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02527.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02527") -public class BenchmarkTest02527 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02527"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02528.java b/OWASP DATASET CLEANED/BenchmarkTest02528.java deleted file mode 100644 index b9e228ab916f7d0af9dbb3bb3bbfa0a45c1764fb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02528.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02528") -public class BenchmarkTest02528 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02528"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02529.java b/OWASP DATASET CLEANED/BenchmarkTest02529.java deleted file mode 100644 index 1402bf95fb3d97e5ce11c44ba247c05da5896573..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02529.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02529") -public class BenchmarkTest02529 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02529"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map32022 = new java.util.HashMap(); - map32022.put("keyA-32022", "a_Value"); // put some stuff in the collection - map32022.put("keyB-32022", param); // put it in a collection - map32022.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map32022.get("keyB-32022"); // get it back out - bar = (String) map32022.get("keyA-32022"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02530.java b/OWASP DATASET CLEANED/BenchmarkTest02530.java deleted file mode 100644 index 4bce2e6cb7dc5233a098ed6888ddf05e42dfae83..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02530.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02530") -public class BenchmarkTest02530 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02530"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02531.java b/OWASP DATASET CLEANED/BenchmarkTest02531.java deleted file mode 100644 index 4b46ee9f66ea5fdabaac1d1960aed5ff64f77032..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02531.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02531") -public class BenchmarkTest02531 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02531"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02532.java b/OWASP DATASET CLEANED/BenchmarkTest02532.java deleted file mode 100644 index 150e8585e3fc78dcdc8e98646cb7b44f462694f4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02532.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02532") -public class BenchmarkTest02532 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02532"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02533.java b/OWASP DATASET CLEANED/BenchmarkTest02533.java deleted file mode 100644 index cf898883c9c661120b86c10831355bac0cba66eb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02533.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02533") -public class BenchmarkTest02533 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02533"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02534.java b/OWASP DATASET CLEANED/BenchmarkTest02534.java deleted file mode 100644 index e2fceaffed567e1b9d34383705b6aab3220587ab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02534.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02534") -public class BenchmarkTest02534 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02534"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02535.java b/OWASP DATASET CLEANED/BenchmarkTest02535.java deleted file mode 100644 index f39245478ba424aae8c1668987161e94593ddca2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02535.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02535") -public class BenchmarkTest02535 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02535"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02536.java b/OWASP DATASET CLEANED/BenchmarkTest02536.java deleted file mode 100644 index 2c9e1b66bdb227fd4560ec9b4a48b3e518b9625a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02536.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02536") -public class BenchmarkTest02536 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02536"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02537.java b/OWASP DATASET CLEANED/BenchmarkTest02537.java deleted file mode 100644 index bd2943ccd2ccd98193fa51994ef95445f0c12554..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02537.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02537") -public class BenchmarkTest02537 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02537"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02538.java b/OWASP DATASET CLEANED/BenchmarkTest02538.java deleted file mode 100644 index b2cabaaf6c278fd9287853091d145a22a296d6b8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02538.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02538") -public class BenchmarkTest02538 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02538"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = - "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - Object results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, new Object[] {}, String.class); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a72634 = param; // assign - StringBuilder b72634 = new StringBuilder(a72634); // stick in stringbuilder - b72634.append(" SafeStuff"); // append some safe content - b72634.replace( - b72634.length() - "Chars".length(), - b72634.length(), - "Chars"); // replace some of the end content - java.util.HashMap map72634 = new java.util.HashMap(); - map72634.put("key72634", b72634.toString()); // put in a collection - String c72634 = (String) map72634.get("key72634"); // get it back out - String d72634 = c72634.substring(0, c72634.length() - 1); // extract most of it - String e72634 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d72634.getBytes()))); // B64 encode and decode it - String f72634 = e72634.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g72634 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g72634); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02539.java b/OWASP DATASET CLEANED/BenchmarkTest02539.java deleted file mode 100644 index e482541d10ff91566f4bc19ff5151029effcc3c7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02539.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02539") -public class BenchmarkTest02539 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02539"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a9290 = param; // assign - StringBuilder b9290 = new StringBuilder(a9290); // stick in stringbuilder - b9290.append(" SafeStuff"); // append some safe content - b9290.replace( - b9290.length() - "Chars".length(), - b9290.length(), - "Chars"); // replace some of the end content - java.util.HashMap map9290 = new java.util.HashMap(); - map9290.put("key9290", b9290.toString()); // put in a collection - String c9290 = (String) map9290.get("key9290"); // get it back out - String d9290 = c9290.substring(0, c9290.length() - 1); // extract most of it - String e9290 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d9290.getBytes()))); // B64 encode and decode it - String f9290 = e9290.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g9290 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g9290); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02540.java b/OWASP DATASET CLEANED/BenchmarkTest02540.java deleted file mode 100644 index b13746351e41de3d64952f12b86c20abac00d8c7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02540.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02540") -public class BenchmarkTest02540 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02540"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02541.java b/OWASP DATASET CLEANED/BenchmarkTest02541.java deleted file mode 100644 index 03d91c93d148354fd6ea83a8ea93763bfc9f3146..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02541.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02541") -public class BenchmarkTest02541 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02541"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02542.java b/OWASP DATASET CLEANED/BenchmarkTest02542.java deleted file mode 100644 index 2302f093cc0997d9e47a411acd8c9585a60c09bd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02542.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02542") -public class BenchmarkTest02542 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02542"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02543.java b/OWASP DATASET CLEANED/BenchmarkTest02543.java deleted file mode 100644 index 2adafc876e3743c9287cd6bb4cf8dab89b443470..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02543.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02543") -public class BenchmarkTest02543 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02543"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02544.java b/OWASP DATASET CLEANED/BenchmarkTest02544.java deleted file mode 100644 index e4e89da07969068add08789ccaec9b217a410876..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02544.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02544") -public class BenchmarkTest02544 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02544"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02545.java b/OWASP DATASET CLEANED/BenchmarkTest02545.java deleted file mode 100644 index f471f880b1e1df63237f2add1e59b0e75db36344..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02545.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02545") -public class BenchmarkTest02545 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02545"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02546.java b/OWASP DATASET CLEANED/BenchmarkTest02546.java deleted file mode 100644 index 3e398043ceb6a78002eb0c813f8733ec425ab0a2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02546.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02546") -public class BenchmarkTest02546 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String[] values = request.getParameterValues("BenchmarkTest02546"); - String param; - if (values != null && values.length > 0) param = values[0]; - else param = ""; - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02547.java b/OWASP DATASET CLEANED/BenchmarkTest02547.java deleted file mode 100644 index 5d568009bc80bc2982cef3918c010f8eeaab12b1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02547.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02547") -public class BenchmarkTest02547 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02547" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02547" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02547" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02548.java b/OWASP DATASET CLEANED/BenchmarkTest02548.java deleted file mode 100644 index a71f6031e566d999c6f0139bd52a2ab9044ac3cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02548.java +++ /dev/null @@ -1,186 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02548") -public class BenchmarkTest02548 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02548" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02548" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02548" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02549.java b/OWASP DATASET CLEANED/BenchmarkTest02549.java deleted file mode 100644 index 5f6795d7b206d7e4ccf19cc1703ac7e55bff5e36..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02549.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02549") -public class BenchmarkTest02549 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02549" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02549" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02549" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz12557 = new StringBuilder(param); - String bar = sbxyz12557.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02550.java b/OWASP DATASET CLEANED/BenchmarkTest02550.java deleted file mode 100644 index 4f3ba38d1c532a3fea1b1268857bfdc1606c66f1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02550.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02550") -public class BenchmarkTest02550 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02550" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02550" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02550" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02551.java b/OWASP DATASET CLEANED/BenchmarkTest02551.java deleted file mode 100644 index 6ad19e67a903201e3846a2793d26759c6f863d18..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02551.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02551") -public class BenchmarkTest02551 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02551" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02551" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02551" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz98255 = new StringBuilder(param); - bar = sbxyz98255.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02552.java b/OWASP DATASET CLEANED/BenchmarkTest02552.java deleted file mode 100644 index bb6f1af3cfe9d61b84ef15c7e7676048b20fbaaa..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02552.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-02/BenchmarkTest02552") -public class BenchmarkTest02552 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02552" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02552" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02552" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - // java.security.SecureRandom random = new java.security.SecureRandom(); - // byte[] iv = random.generateSeed(16); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02553.java b/OWASP DATASET CLEANED/BenchmarkTest02553.java deleted file mode 100644 index b94b3ab19e9970ee127cdabd33666bf4d699597a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02553.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02553") -public class BenchmarkTest02553 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02553" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02553" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02553" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - javax.naming.directory.DirContext ctx = ads.getDirContext(); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - // System.out.println("Filter " + filter); - boolean found = false; - javax.naming.NamingEnumeration results = - ctx.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map11026 = new java.util.HashMap(); - map11026.put("keyA-11026", "a_Value"); // put some stuff in the collection - map11026.put("keyB-11026", param); // put it in a collection - map11026.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map11026.get("keyB-11026"); // get it back out - bar = (String) map11026.get("keyA-11026"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02554.java b/OWASP DATASET CLEANED/BenchmarkTest02554.java deleted file mode 100644 index 159fd37e2d55ccf362c96efc2c3d1fa48416e34d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02554.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02554") -public class BenchmarkTest02554 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02554" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02554" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02554" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02555.java b/OWASP DATASET CLEANED/BenchmarkTest02555.java deleted file mode 100644 index 5040e6f2bb258a55acd746be1799ab0185175c84..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02555.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02555") -public class BenchmarkTest02555 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02555" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02555" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02555" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02556.java b/OWASP DATASET CLEANED/BenchmarkTest02556.java deleted file mode 100644 index a9966eef2d0a8b981ac159644c75bb11832dc304..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02556.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02556") -public class BenchmarkTest02556 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02556" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02556" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02556" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02557.java b/OWASP DATASET CLEANED/BenchmarkTest02557.java deleted file mode 100644 index 3a4f5190348bc73a8b6678badd0b8ad12e4708b0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02557.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02557") -public class BenchmarkTest02557 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02557" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02557" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02557" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02558.java b/OWASP DATASET CLEANED/BenchmarkTest02558.java deleted file mode 100644 index 63a38c51eaae1cdf25f91cca418dd9a33a8f3432..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02558.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02558") -public class BenchmarkTest02558 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02558" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02558" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02558" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02559.java b/OWASP DATASET CLEANED/BenchmarkTest02559.java deleted file mode 100644 index 1d439d969daeb2e1443c83737e526b41cddddbd2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02559.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02559") -public class BenchmarkTest02559 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02559" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02559" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02559" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // FILE URIs are tricky because they are different between Mac and Windows because of lack - // of standardization. - // Mac requires an extra slash for some reason. - String startURIslashes = ""; - if (System.getProperty("os.name").indexOf("Windows") != -1) - if (System.getProperty("os.name").indexOf("Windows") != -1) startURIslashes = "/"; - else startURIslashes = "//"; - - try { - java.net.URI fileURI = - new java.net.URI( - "file:" - + startURIslashes - + org.owasp.benchmark.helpers.Utils.TESTFILES_DIR - .replace('\\', '/') - .replace(' ', '_') - + bar); - java.io.File fileTarget = new java.io.File(fileURI); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } catch (java.net.URISyntaxException e) { - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02560.java b/OWASP DATASET CLEANED/BenchmarkTest02560.java deleted file mode 100644 index c996d248dd4338489847a63c75bf2fb7c9158e9e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02560.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02560") -public class BenchmarkTest02560 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02560" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02560" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02560" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02561.java b/OWASP DATASET CLEANED/BenchmarkTest02561.java deleted file mode 100644 index 6e8aa81f74e9e2a3defeed329f23d5a0f977d824..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02561.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02561") -public class BenchmarkTest02561 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02561" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02561" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02561" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02562.java b/OWASP DATASET CLEANED/BenchmarkTest02562.java deleted file mode 100644 index cf88d163c41aa8da0f93464bf6f0fd7a7e292589..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02562.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02562") -public class BenchmarkTest02562 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02562" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02562" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02562" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02563.java b/OWASP DATASET CLEANED/BenchmarkTest02563.java deleted file mode 100644 index f5840b2c9766c1e9d4e50a9a16658571bf2e4319..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02563.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02563") -public class BenchmarkTest02563 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02563" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02563" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02563" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a99746 = param; // assign - StringBuilder b99746 = new StringBuilder(a99746); // stick in stringbuilder - b99746.append(" SafeStuff"); // append some safe content - b99746.replace( - b99746.length() - "Chars".length(), - b99746.length(), - "Chars"); // replace some of the end content - java.util.HashMap map99746 = new java.util.HashMap(); - map99746.put("key99746", b99746.toString()); // put in a collection - String c99746 = (String) map99746.get("key99746"); // get it back out - String d99746 = c99746.substring(0, c99746.length() - 1); // extract most of it - String e99746 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d99746.getBytes()))); // B64 encode and decode it - String f99746 = e99746.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g99746 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g99746); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02564.java b/OWASP DATASET CLEANED/BenchmarkTest02564.java deleted file mode 100644 index f670c9d3645594e4f24471761f2079615f73ba10..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02564.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02564") -public class BenchmarkTest02564 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02564" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02564" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02564" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(new java.io.File(fileName), false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02565.java b/OWASP DATASET CLEANED/BenchmarkTest02565.java deleted file mode 100644 index 0dcf90dc4d32d4e19d49724e478e128a7c0db04a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02565.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02565") -public class BenchmarkTest02565 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02565" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02565" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02565" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02566.java b/OWASP DATASET CLEANED/BenchmarkTest02566.java deleted file mode 100644 index 24b79ee3cdd66ee5c3164fee5e76d2c0628180f2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02566.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02566") -public class BenchmarkTest02566 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02566" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02566" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02566" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - try ( - // Create the file first so the test won't throw an exception if it doesn't exist. - // Note: Don't actually do this because this method signature could cause a tool to find - // THIS file constructor - // as a vuln, rather than the File signature we are trying to actually test. - // If necessary, just run the benchmark twice. The 1st run should create all the necessary - // files. - // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile(); - - java.io.FileOutputStream fos = - new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) { - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02567.java b/OWASP DATASET CLEANED/BenchmarkTest02567.java deleted file mode 100644 index 33dc7378865c30e66007d83159f307266ee0a877..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02567.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02567") -public class BenchmarkTest02567 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02567" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02567" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02567" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02568.java b/OWASP DATASET CLEANED/BenchmarkTest02568.java deleted file mode 100644 index cbf96177a0bd4306757e6e10782ad01059d65696..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02568.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02568") -public class BenchmarkTest02568 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02568" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02568" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02568" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02569.java b/OWASP DATASET CLEANED/BenchmarkTest02569.java deleted file mode 100644 index d871824211b7fe704cacd85f70c77fb1c8cbde03..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02569.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02569") -public class BenchmarkTest02569 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02569" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02569" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02569" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02570.java b/OWASP DATASET CLEANED/BenchmarkTest02570.java deleted file mode 100644 index 2c0198a331ef808f8604c3ee139d9ee4042cda85..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02570.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02570") -public class BenchmarkTest02570 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02570" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02570" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02570" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - java.io.InputStream is = null; - - try { - java.nio.file.Path path = java.nio.file.Paths.get(fileName); - is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); - byte[] b = new byte[1000]; - int size = is.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - is.close(); - } catch (Exception e) { - System.out.println("Couldn't open InputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting InputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02571.java b/OWASP DATASET CLEANED/BenchmarkTest02571.java deleted file mode 100644 index c8e58a166182dad5e187bc9c1636747e69dd1336..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02571.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02571") -public class BenchmarkTest02571 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02571" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02571" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02571" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))"; - Object[] filters = new Object[] {"The streetz 4 Ms bar"}; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, filters, sc); - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02572.java b/OWASP DATASET CLEANED/BenchmarkTest02572.java deleted file mode 100644 index 5dd09df1ecd03dcc5b6fbaf2cc02f9480199936f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02572.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/ldapi-00/BenchmarkTest02572") -public class BenchmarkTest02572 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02572" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02572" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02572" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager(); - try { - response.setContentType("text/html;charset=UTF-8"); - String base = "ou=users,ou=system"; - javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls(); - sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); - String filter = "(&(objectclass=person)(uid=" + bar + "))"; - - javax.naming.directory.DirContext ctx = ads.getDirContext(); - javax.naming.directory.InitialDirContext idc = - (javax.naming.directory.InitialDirContext) ctx; - boolean found = false; - javax.naming.NamingEnumeration results = - idc.search(base, filter, sc); - - while (results.hasMore()) { - javax.naming.directory.SearchResult sr = - (javax.naming.directory.SearchResult) results.next(); - javax.naming.directory.Attributes attrs = sr.getAttributes(); - - javax.naming.directory.Attribute attr = attrs.get("uid"); - javax.naming.directory.Attribute attr2 = attrs.get("street"); - if (attr != null) { - response.getWriter() - .println( - "LDAP query results:
" - + "Record found with name " - + attr.get() - + "
" - + "Address: " - + attr2.get() - + "
"); - // System.out.println("record found " + attr.get()); - found = true; - } - } - if (!found) { - response.getWriter() - .println( - "LDAP query results: nothing found for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter)); - } - } catch (javax.naming.NamingException e) { - throw new ServletException(e); - } finally { - try { - ads.closeDirContext(); - } catch (Exception e) { - throw new ServletException(e); - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02573.java b/OWASP DATASET CLEANED/BenchmarkTest02573.java deleted file mode 100644 index 4b47a1a36ba610c6bc1d5ef0eba8919f5c3edc93..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02573.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02573") -public class BenchmarkTest02573 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02573" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02573" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02573" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02574.java b/OWASP DATASET CLEANED/BenchmarkTest02574.java deleted file mode 100644 index 95e612cc995331a5699aaabaff40e4d44a1213d2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02574.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02574") -public class BenchmarkTest02574 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02574" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02574" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02574" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02575.java b/OWASP DATASET CLEANED/BenchmarkTest02575.java deleted file mode 100644 index 551e46e638f8df9b366811c1ef9954f04225d1d2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02575.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02575") -public class BenchmarkTest02575 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02575" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02575" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02575" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02576.java b/OWASP DATASET CLEANED/BenchmarkTest02576.java deleted file mode 100644 index 4dab252c4af4d086b3c2488247eca2b3b3189bf0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02576.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02576") -public class BenchmarkTest02576 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02576" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02576" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02576" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02577.java b/OWASP DATASET CLEANED/BenchmarkTest02577.java deleted file mode 100644 index 2cfe263e5c85b37d428a2450b6f64ec606748017..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02577.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02577") -public class BenchmarkTest02577 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02577" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02577" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02577" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02578.java b/OWASP DATASET CLEANED/BenchmarkTest02578.java deleted file mode 100644 index ee32846b0229127e0c5ee2d2cf0a7f82c2d8cdf9..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02578.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02578") -public class BenchmarkTest02578 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02578" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02578" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02578" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02579.java b/OWASP DATASET CLEANED/BenchmarkTest02579.java deleted file mode 100644 index fb09d7ca44571a04ca2df69c8d98ac6855070b2b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02579.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02579") -public class BenchmarkTest02579 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02579" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02579" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02579" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02580.java b/OWASP DATASET CLEANED/BenchmarkTest02580.java deleted file mode 100644 index 479f09cb9cb12dba471663b224b4d16b635af72a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02580.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02580") -public class BenchmarkTest02580 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02580" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02580" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02580" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz1658 = new StringBuilder(param); - String bar = sbxyz1658.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02581.java b/OWASP DATASET CLEANED/BenchmarkTest02581.java deleted file mode 100644 index d171006187c418aa57dea4165111c330a34322b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02581.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02581") -public class BenchmarkTest02581 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02581" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02581" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02581" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02582.java b/OWASP DATASET CLEANED/BenchmarkTest02582.java deleted file mode 100644 index 38a55a955ff087f17c0f0c21a719ba6fd17a61e3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02582.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02582") -public class BenchmarkTest02582 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02582" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02582" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02582" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz18070 = new StringBuilder(param); - String bar = sbxyz18070.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02583.java b/OWASP DATASET CLEANED/BenchmarkTest02583.java deleted file mode 100644 index 572b1a1cb7a4f166279fd486a67f58c688d01376..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02583.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02583") -public class BenchmarkTest02583 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02583" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02583" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02583" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02584.java b/OWASP DATASET CLEANED/BenchmarkTest02584.java deleted file mode 100644 index a2dfc9512c9fa9023af25f0dbdbc142ba6291b2c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02584.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02584") -public class BenchmarkTest02584 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02584" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02584" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02584" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz36210 = new StringBuilder(param); - String bar = sbxyz36210.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02585.java b/OWASP DATASET CLEANED/BenchmarkTest02585.java deleted file mode 100644 index c968c96c80f8aa93734d16c2116be7b71a34a6c5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02585.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02585") -public class BenchmarkTest02585 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02585" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02585" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02585" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02586.java b/OWASP DATASET CLEANED/BenchmarkTest02586.java deleted file mode 100644 index cb53cfe7352a948604ef05c7b52a75d5b754506a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02586.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02586") -public class BenchmarkTest02586 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02586" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02586" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02586" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02587.java b/OWASP DATASET CLEANED/BenchmarkTest02587.java deleted file mode 100644 index b9f3bad87cae6ae9babc5d07a0cc90c33ba9462c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02587.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02587") -public class BenchmarkTest02587 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02587" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02587" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02587" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a93081 = param; // assign - StringBuilder b93081 = new StringBuilder(a93081); // stick in stringbuilder - b93081.append(" SafeStuff"); // append some safe content - b93081.replace( - b93081.length() - "Chars".length(), - b93081.length(), - "Chars"); // replace some of the end content - java.util.HashMap map93081 = new java.util.HashMap(); - map93081.put("key93081", b93081.toString()); // put in a collection - String c93081 = (String) map93081.get("key93081"); // get it back out - String d93081 = c93081.substring(0, c93081.length() - 1); // extract most of it - String e93081 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d93081.getBytes()))); // B64 encode and decode it - String f93081 = e93081.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f93081); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02588.java b/OWASP DATASET CLEANED/BenchmarkTest02588.java deleted file mode 100644 index 1000a79780b2317c0de27a145edc6783c5040341..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02588.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02588") -public class BenchmarkTest02588 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02588" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02588" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02588" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a1227 = param; // assign - StringBuilder b1227 = new StringBuilder(a1227); // stick in stringbuilder - b1227.append(" SafeStuff"); // append some safe content - b1227.replace( - b1227.length() - "Chars".length(), - b1227.length(), - "Chars"); // replace some of the end content - java.util.HashMap map1227 = new java.util.HashMap(); - map1227.put("key1227", b1227.toString()); // put in a collection - String c1227 = (String) map1227.get("key1227"); // get it back out - String d1227 = c1227.substring(0, c1227.length() - 1); // extract most of it - String e1227 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d1227.getBytes()))); // B64 encode and decode it - String f1227 = e1227.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f1227); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02589.java b/OWASP DATASET CLEANED/BenchmarkTest02589.java deleted file mode 100644 index fa117cd30a7f5c059663057d59f2446c4119d7a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02589.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02589") -public class BenchmarkTest02589 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02589" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02589" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02589" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02590.java b/OWASP DATASET CLEANED/BenchmarkTest02590.java deleted file mode 100644 index 472d1ac0a26f18380b0523432fd4930c4433ce9c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02590.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02590") -public class BenchmarkTest02590 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02590" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02590" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02590" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map35520 = new java.util.HashMap(); - map35520.put("keyA-35520", "a_Value"); // put some stuff in the collection - map35520.put("keyB-35520", param); // put it in a collection - map35520.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map35520.get("keyB-35520"); // get it back out - bar = (String) map35520.get("keyA-35520"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02591.java b/OWASP DATASET CLEANED/BenchmarkTest02591.java deleted file mode 100644 index a64020402660e97d58ab42099d77464590dfb13d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02591.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02591") -public class BenchmarkTest02591 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02591" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02591" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02591" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz9811 = new StringBuilder(param); - String bar = sbxyz9811.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02592.java b/OWASP DATASET CLEANED/BenchmarkTest02592.java deleted file mode 100644 index 886ab6d6cd7f262913ddec3223c0ed576ec28391..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02592.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02592") -public class BenchmarkTest02592 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02592" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02592" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02592" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {bar, "b"}; - response.getWriter().printf("Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz52014 = new StringBuilder(param); - bar = sbxyz52014.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02593.java b/OWASP DATASET CLEANED/BenchmarkTest02593.java deleted file mode 100644 index 13f2a514ec4b268d54616f8bda437d55a638f385..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02593.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02593") -public class BenchmarkTest02593 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02593" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02593" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02593" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02594.java b/OWASP DATASET CLEANED/BenchmarkTest02594.java deleted file mode 100644 index 004f8147d96da69798845724a6dcb511644557a3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02594.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02594") -public class BenchmarkTest02594 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02594" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02594" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02594" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02595.java b/OWASP DATASET CLEANED/BenchmarkTest02595.java deleted file mode 100644 index d73a5e861ff4b0429549f88c7909e7f84bc02673..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02595.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02595") -public class BenchmarkTest02595 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02595" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02595" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02595" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02596.java b/OWASP DATASET CLEANED/BenchmarkTest02596.java deleted file mode 100644 index 9af55845ce0c8442667ce4f8c9c33bc35b4bffb3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02596.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02596") -public class BenchmarkTest02596 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02596" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02596" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02596" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02597.java b/OWASP DATASET CLEANED/BenchmarkTest02597.java deleted file mode 100644 index cd0b2c811c80be18d5d584ce506d4ed6e1d6d2b6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02597.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02597") -public class BenchmarkTest02597 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02597" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02597" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02597" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz19350 = new StringBuilder(param); - bar = sbxyz19350.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02598.java b/OWASP DATASET CLEANED/BenchmarkTest02598.java deleted file mode 100644 index ae37642d0fe27c1e5c4a40c7d9e7dd0387b7407d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02598.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02598") -public class BenchmarkTest02598 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02598" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02598" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02598" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02599.java b/OWASP DATASET CLEANED/BenchmarkTest02599.java deleted file mode 100644 index 1026da9e882db8c6d62467e51275a70125ac60e8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02599.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02599") -public class BenchmarkTest02599 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02599" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02599" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02599" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02600.java b/OWASP DATASET CLEANED/BenchmarkTest02600.java deleted file mode 100644 index d2f23d531df128f92f1526eb3bf194528b500d54..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02600.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02600") -public class BenchmarkTest02600 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02600" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02600" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02600" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02601.java b/OWASP DATASET CLEANED/BenchmarkTest02601.java deleted file mode 100644 index b5cd901e477e001ffd506f279a36c0b81dae7738..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02601.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02601") -public class BenchmarkTest02601 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02601" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02601" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02601" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - int length = 1; - if (bar != null) { - length = bar.length(); - response.getWriter().write(bar.toCharArray(), 0, length); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02602.java b/OWASP DATASET CLEANED/BenchmarkTest02602.java deleted file mode 100644 index 19b289be499aa1e9443526551db070ae2f7c6e60..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02602.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02602") -public class BenchmarkTest02602 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02602" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02602" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02602" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a3617 = param; // assign - StringBuilder b3617 = new StringBuilder(a3617); // stick in stringbuilder - b3617.append(" SafeStuff"); // append some safe content - b3617.replace( - b3617.length() - "Chars".length(), - b3617.length(), - "Chars"); // replace some of the end content - java.util.HashMap map3617 = new java.util.HashMap(); - map3617.put("key3617", b3617.toString()); // put in a collection - String c3617 = (String) map3617.get("key3617"); // get it back out - String d3617 = c3617.substring(0, c3617.length() - 1); // extract most of it - String e3617 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d3617.getBytes()))); // B64 encode and decode it - String f3617 = e3617.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f3617); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02603.java b/OWASP DATASET CLEANED/BenchmarkTest02603.java deleted file mode 100644 index abebfd0638d9407788e818fdd5bbcc44dbd94785..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02603.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02603") -public class BenchmarkTest02603 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02603" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02603" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02603" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02604.java b/OWASP DATASET CLEANED/BenchmarkTest02604.java deleted file mode 100644 index 2a3a5d76530e7ff6cb00502dc415839361bf6039..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02604.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02604") -public class BenchmarkTest02604 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02604" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02604" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02604" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a92079 = param; // assign - StringBuilder b92079 = new StringBuilder(a92079); // stick in stringbuilder - b92079.append(" SafeStuff"); // append some safe content - b92079.replace( - b92079.length() - "Chars".length(), - b92079.length(), - "Chars"); // replace some of the end content - java.util.HashMap map92079 = new java.util.HashMap(); - map92079.put("key92079", b92079.toString()); // put in a collection - String c92079 = (String) map92079.get("key92079"); // get it back out - String d92079 = c92079.substring(0, c92079.length() - 1); // extract most of it - String e92079 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d92079.getBytes()))); // B64 encode and decode it - String f92079 = e92079.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f92079); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02605.java b/OWASP DATASET CLEANED/BenchmarkTest02605.java deleted file mode 100644 index b9b710f45b987188c0a30cd638c14dc80207a164..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02605.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02605") -public class BenchmarkTest02605 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02605" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02605" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02605" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02606.java b/OWASP DATASET CLEANED/BenchmarkTest02606.java deleted file mode 100644 index 2f5b2c76bf51bc6ccdf4c303d9ee4ea962c19080..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02606.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02606") -public class BenchmarkTest02606 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02606" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02606" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02606" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02607.java b/OWASP DATASET CLEANED/BenchmarkTest02607.java deleted file mode 100644 index 1e6dd16122b8c1e574cf6bf4215170afddf600cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02607.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02607") -public class BenchmarkTest02607 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02607" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02607" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02607" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz75490 = new StringBuilder(param); - String bar = sbxyz75490.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02608.java b/OWASP DATASET CLEANED/BenchmarkTest02608.java deleted file mode 100644 index 3da7c0990e8bbbb680d7b8aaa4df50bf8b81c125..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02608.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02608") -public class BenchmarkTest02608 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02608" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02608" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02608" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02609.java b/OWASP DATASET CLEANED/BenchmarkTest02609.java deleted file mode 100644 index cc2501d44d9b0507c2fa279b410d56ffd39eafc3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02609.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02609") -public class BenchmarkTest02609 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02609" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02609" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02609" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02610.java b/OWASP DATASET CLEANED/BenchmarkTest02610.java deleted file mode 100644 index 3f8464cf60213a79813ed9006f09186ac719a386..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02610.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02610") -public class BenchmarkTest02610 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02610" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02610" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02610" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02611.java b/OWASP DATASET CLEANED/BenchmarkTest02611.java deleted file mode 100644 index 2893bd5c3c5e3b51b65edb50fff14fa287c196b6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02611.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02611") -public class BenchmarkTest02611 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02611" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02611" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02611" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = ""; - String a1 = ""; - String a2 = ""; - String[] args = null; - String osName = System.getProperty("os.name"); - - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - cmd = "echo "; - args = new String[] {a1, a2, cmd, bar}; - } else { - a1 = "sh"; - a2 = "-c"; - cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("ls "); - args = new String[] {a1, a2, cmd + bar}; - } - - String[] argsEnv = {"foo=bar"}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02612.java b/OWASP DATASET CLEANED/BenchmarkTest02612.java deleted file mode 100644 index 51ce32fa5338fc72554ecaf093d6594360572a5f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02612.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02612") -public class BenchmarkTest02612 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02612" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02612" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02612" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02613.java b/OWASP DATASET CLEANED/BenchmarkTest02613.java deleted file mode 100644 index 7f1225efb656a77144db665f8b461e2594b17ad0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02613.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02613") -public class BenchmarkTest02613 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02613" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02613" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02613" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02614.java b/OWASP DATASET CLEANED/BenchmarkTest02614.java deleted file mode 100644 index f5161a75de13a0cd5f9ac86adbddb93b31c73c53..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02614.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02614") -public class BenchmarkTest02614 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02614" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02614" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02614" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - getNextNumber(numGen, randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeBystander"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - void getNextNumber(java.util.Random generator, byte[] barray) { - generator.nextBytes(barray); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02615.java b/OWASP DATASET CLEANED/BenchmarkTest02615.java deleted file mode 100644 index ac82d105a8c4266c48e4e44894929dde30dd7e70..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02615.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02615") -public class BenchmarkTest02615 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02615" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02615" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02615" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02616.java b/OWASP DATASET CLEANED/BenchmarkTest02616.java deleted file mode 100644 index 1a16bfd33e5516d41cc8c73472cdacfeb66b1c80..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02616.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02616") -public class BenchmarkTest02616 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02616" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02616" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02616" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); - double rand = getNextNumber(numGen); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonatella"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - double getNextNumber(java.util.Random generator) { - return generator.nextDouble(); - } - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02617.java b/OWASP DATASET CLEANED/BenchmarkTest02617.java deleted file mode 100644 index a8aa485032081c0ae0a5d13c360ddc16a45f48da..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02617.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02617") -public class BenchmarkTest02617 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02617" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02617" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02617" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - java.security.SecureRandom secureRandomGenerator = - java.security.SecureRandom.getInstance("SHA1PRNG"); - - // Get 40 random bytes - byte[] randomBytes = new byte[40]; - secureRandomGenerator.nextBytes(randomBytes); - - String rememberMeKey = - org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true); - - String user = "SafeByron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextBytes() - TestCase"); - throw new ServletException(e); - } finally { - response.getWriter() - .println( - "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed"); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a80801 = param; // assign - StringBuilder b80801 = new StringBuilder(a80801); // stick in stringbuilder - b80801.append(" SafeStuff"); // append some safe content - b80801.replace( - b80801.length() - "Chars".length(), - b80801.length(), - "Chars"); // replace some of the end content - java.util.HashMap map80801 = new java.util.HashMap(); - map80801.put("key80801", b80801.toString()); // put in a collection - String c80801 = (String) map80801.get("key80801"); // get it back out - String d80801 = c80801.substring(0, c80801.length() - 1); // extract most of it - String e80801 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d80801.getBytes()))); // B64 encode and decode it - String f80801 = e80801.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f80801); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02618.java b/OWASP DATASET CLEANED/BenchmarkTest02618.java deleted file mode 100644 index 1c991613107662be10a6ce21cce9b89f02f2d68c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02618.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02618") -public class BenchmarkTest02618 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02618" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02618" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02618" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02619.java b/OWASP DATASET CLEANED/BenchmarkTest02619.java deleted file mode 100644 index 02ae7e4e10fff0eef73f778c5d0c3803457d6170..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02619.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02619") -public class BenchmarkTest02619 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02619" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02619" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02619" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02620.java b/OWASP DATASET CLEANED/BenchmarkTest02620.java deleted file mode 100644 index f7f8b911daaf72c0c4f5f937ab7c8892576853c1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02620.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02620") -public class BenchmarkTest02620 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02620" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02620" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02620" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99); - String rememberMeKey = Integer.toString(randNumber); - - String user = "SafeInga"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz33222 = new StringBuilder(param); - bar = sbxyz33222.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02621.java b/OWASP DATASET CLEANED/BenchmarkTest02621.java deleted file mode 100644 index ec930dae98e09c4b78abaf2fff8b80f9fceff549..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02621.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02621") -public class BenchmarkTest02621 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02621" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02621" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02621" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz33448 = new StringBuilder(param); - bar = sbxyz33448.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02622.java b/OWASP DATASET CLEANED/BenchmarkTest02622.java deleted file mode 100644 index b31fb2020128e1cb0c48029431c2c3f22e77a3b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02622.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02622") -public class BenchmarkTest02622 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02622" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02622" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02622" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) - request.getSession().setAttribute(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: '10340' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz66849 = new StringBuilder(param); - String bar = sbxyz66849.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02623.java b/OWASP DATASET CLEANED/BenchmarkTest02623.java deleted file mode 100644 index c442ca1f1da1fdb080972e8043f159d5ac9cd713..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02623.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02623") -public class BenchmarkTest02623 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02623" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02623" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02623" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02624.java b/OWASP DATASET CLEANED/BenchmarkTest02624.java deleted file mode 100644 index 4cbe1638ca92b81652550623fc95a8e9b12aca8d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02624.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02624") -public class BenchmarkTest02624 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02624" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02624" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02624" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map3141 = new java.util.HashMap(); - map3141.put("keyA-3141", "a-Value"); // put some stuff in the collection - map3141.put("keyB-3141", param); // put it in a collection - map3141.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map3141.get("keyB-3141"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02625.java b/OWASP DATASET CLEANED/BenchmarkTest02625.java deleted file mode 100644 index 6759a98c584a72cb1ca88949412deaa0e07f1e7d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02625.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02625") -public class BenchmarkTest02625 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02625" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02625" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02625" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map82391 = new java.util.HashMap(); - map82391.put("keyA-82391", "a-Value"); // put some stuff in the collection - map82391.put("keyB-82391", param); // put it in a collection - map82391.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map82391.get("keyB-82391"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02626.java b/OWASP DATASET CLEANED/BenchmarkTest02626.java deleted file mode 100644 index dd8ebc58a88476c8e8b3b3df550633a3040887ec..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02626.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02626") -public class BenchmarkTest02626 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02626" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02626" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02626" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = connection.prepareCall(sql); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02627.java b/OWASP DATASET CLEANED/BenchmarkTest02627.java deleted file mode 100644 index d44339d98c6a5b9afa305933f21dc7792556e1cf..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02627.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02627") -public class BenchmarkTest02627 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02627" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02627" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02627" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02628.java b/OWASP DATASET CLEANED/BenchmarkTest02628.java deleted file mode 100644 index 9985904be4f8be4301048b23ac5dc0843d24ee9d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02628.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02628") -public class BenchmarkTest02628 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02628" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02628" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02628" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map23653 = new java.util.HashMap(); - map23653.put("keyA-23653", "a-Value"); // put some stuff in the collection - map23653.put("keyB-23653", param); // put it in a collection - map23653.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map23653.get("keyB-23653"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02629.java b/OWASP DATASET CLEANED/BenchmarkTest02629.java deleted file mode 100644 index 027f7d1b8bc7416d8284de8c8f62a23d7298a383..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02629.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02629") -public class BenchmarkTest02629 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02629" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02629" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02629" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02630.java b/OWASP DATASET CLEANED/BenchmarkTest02630.java deleted file mode 100644 index 523f2e67543b432caaf1745f3d32bffc13d89be7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02630.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02630") -public class BenchmarkTest02630 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02630" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02630" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02630" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "{call " + bar + "}"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.CallableStatement statement = - connection.prepareCall( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - java.sql.ResultSet rs = statement.executeQuery(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02631.java b/OWASP DATASET CLEANED/BenchmarkTest02631.java deleted file mode 100644 index 722b51f0a1f1272453463a1115a6f02fc9ce0034..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02631.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02631") -public class BenchmarkTest02631 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02631" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02631" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02631" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02632.java b/OWASP DATASET CLEANED/BenchmarkTest02632.java deleted file mode 100644 index 2255aca5d6a71ac06baef5f76e9efba8dba12899..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02632.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02632") -public class BenchmarkTest02632 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02632" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02632" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02632" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = connection.prepareStatement(sql); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02633.java b/OWASP DATASET CLEANED/BenchmarkTest02633.java deleted file mode 100644 index 35d6d6aaea84ab4114370262536f293ad8b5f835..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02633.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02633") -public class BenchmarkTest02633 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02633" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02633" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02633" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a12213 = param; // assign - StringBuilder b12213 = new StringBuilder(a12213); // stick in stringbuilder - b12213.append(" SafeStuff"); // append some safe content - b12213.replace( - b12213.length() - "Chars".length(), - b12213.length(), - "Chars"); // replace some of the end content - java.util.HashMap map12213 = new java.util.HashMap(); - map12213.put("key12213", b12213.toString()); // put in a collection - String c12213 = (String) map12213.get("key12213"); // get it back out - String d12213 = c12213.substring(0, c12213.length() - 1); // extract most of it - String e12213 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d12213.getBytes()))); // B64 encode and decode it - String f12213 = e12213.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g12213 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g12213); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02634.java b/OWASP DATASET CLEANED/BenchmarkTest02634.java deleted file mode 100644 index 9f0a60169d8da1c4729928a25fd7e61f42038e99..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02634.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02634") -public class BenchmarkTest02634 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02634" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02634" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02634" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02635.java b/OWASP DATASET CLEANED/BenchmarkTest02635.java deleted file mode 100644 index 4e40f0ede19383ade74705655328ecf69b9202fd..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02635.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02635") -public class BenchmarkTest02635 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02635" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02635" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02635" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02636.java b/OWASP DATASET CLEANED/BenchmarkTest02636.java deleted file mode 100644 index c1e2b610a1c048023d84dab82e7c467403d26299..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02636.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02636") -public class BenchmarkTest02636 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02636" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02636" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02636" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02637.java b/OWASP DATASET CLEANED/BenchmarkTest02637.java deleted file mode 100644 index f830d309c1ad54e7c0ff1dff12cf6575d6e7cb98..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02637.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02637") -public class BenchmarkTest02637 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02637" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02637" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02637" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02638.java b/OWASP DATASET CLEANED/BenchmarkTest02638.java deleted file mode 100644 index f43320633f81bc868e7fb4c1bce69239f1da1a38..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02638.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02638") -public class BenchmarkTest02638 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02638" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02638" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02638" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02639.java b/OWASP DATASET CLEANED/BenchmarkTest02639.java deleted file mode 100644 index adf75307ae406f90597696ce06f0c92f0b31c88c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02639.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02639") -public class BenchmarkTest02639 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02639" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02639" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02639" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a57676 = param; // assign - StringBuilder b57676 = new StringBuilder(a57676); // stick in stringbuilder - b57676.append(" SafeStuff"); // append some safe content - b57676.replace( - b57676.length() - "Chars".length(), - b57676.length(), - "Chars"); // replace some of the end content - java.util.HashMap map57676 = new java.util.HashMap(); - map57676.put("key57676", b57676.toString()); // put in a collection - String c57676 = (String) map57676.get("key57676"); // get it back out - String d57676 = c57676.substring(0, c57676.length() - 1); // extract most of it - String e57676 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d57676.getBytes()))); // B64 encode and decode it - String f57676 = e57676.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g57676 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g57676); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02640.java b/OWASP DATASET CLEANED/BenchmarkTest02640.java deleted file mode 100644 index cb1f90a8e2c5b8bbf23da01ff9b85d6f5e1e907f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02640.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02640") -public class BenchmarkTest02640 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02640" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02640" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02640" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring execute method doesn't return results."); - - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02641.java b/OWASP DATASET CLEANED/BenchmarkTest02641.java deleted file mode 100644 index 5b05102677722324603cec012ed24a44a4421db2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02641.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02641") -public class BenchmarkTest02641 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02641" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02641" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02641" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02642.java b/OWASP DATASET CLEANED/BenchmarkTest02642.java deleted file mode 100644 index c83ea74914f71073837e4966c70f5d30bbb6a93d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02642.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02642") -public class BenchmarkTest02642 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02642" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02642" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02642" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02643.java b/OWASP DATASET CLEANED/BenchmarkTest02643.java deleted file mode 100644 index 4fda89f13ed8afb88583a74899df640a16179c32..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02643.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02643") -public class BenchmarkTest02643 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02643" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02643" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02643" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02644.java b/OWASP DATASET CLEANED/BenchmarkTest02644.java deleted file mode 100644 index 75ae0a8bef164800935acb1da3cd50f84beb0e38..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02644.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02644") -public class BenchmarkTest02644 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02644" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02644" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02644" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02645.java b/OWASP DATASET CLEANED/BenchmarkTest02645.java deleted file mode 100644 index 7d540ce0dffff2ce95b5072ebd141faed9ce385b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02645.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02645") -public class BenchmarkTest02645 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02645" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02645" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02645" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02646.java b/OWASP DATASET CLEANED/BenchmarkTest02646.java deleted file mode 100644 index 78c98a8c7fca93d5df91432bedd2086f9735a2ae..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02646.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02646") -public class BenchmarkTest02646 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02646" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02646" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02646" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02647.java b/OWASP DATASET CLEANED/BenchmarkTest02647.java deleted file mode 100644 index 0b796cc62ffefeb18a0a1fb09fe784164ab54b76..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02647.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-05/BenchmarkTest02647") -public class BenchmarkTest02647 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02647" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02647" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02647" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.addBatch(sql); - int[] counts = statement.executeBatch(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02648.java b/OWASP DATASET CLEANED/BenchmarkTest02648.java deleted file mode 100644 index d272e74a96a09580c4af78debc0b3551ff728368..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02648.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02648") -public class BenchmarkTest02648 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02648" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02648" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02648" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map91488 = new java.util.HashMap(); - map91488.put("keyA-91488", "a_Value"); // put some stuff in the collection - map91488.put("keyB-91488", param); // put it in a collection - map91488.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map91488.get("keyB-91488"); // get it back out - bar = (String) map91488.get("keyA-91488"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02649.java b/OWASP DATASET CLEANED/BenchmarkTest02649.java deleted file mode 100644 index 6cd490aacb7aa4bfdf1292aa5435e63c5cccb729..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02649.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02649") -public class BenchmarkTest02649 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02649" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02649" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02649" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02650.java b/OWASP DATASET CLEANED/BenchmarkTest02650.java deleted file mode 100644 index fcea66e0df784addb86a0f7e03866573556d034b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02650.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02650") -public class BenchmarkTest02650 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02650" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02650" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02650" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02651.java b/OWASP DATASET CLEANED/BenchmarkTest02651.java deleted file mode 100644 index 27d089d187a2b67ec7404c3b3656b62404808f95..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02651.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02651") -public class BenchmarkTest02651 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02651" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02651" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02651" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02652.java b/OWASP DATASET CLEANED/BenchmarkTest02652.java deleted file mode 100644 index 0dd7312ffe03aacfc8697911975bfda963f35e84..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02652.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02652") -public class BenchmarkTest02652 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02652" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02652" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02652" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new String[] {"username", "password"}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a25323 = param; // assign - StringBuilder b25323 = new StringBuilder(a25323); // stick in stringbuilder - b25323.append(" SafeStuff"); // append some safe content - b25323.replace( - b25323.length() - "Chars".length(), - b25323.length(), - "Chars"); // replace some of the end content - java.util.HashMap map25323 = new java.util.HashMap(); - map25323.put("key25323", b25323.toString()); // put in a collection - String c25323 = (String) map25323.get("key25323"); // get it back out - String d25323 = c25323.substring(0, c25323.length() - 1); // extract most of it - String e25323 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d25323.getBytes()))); // B64 encode and decode it - String f25323 = e25323.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g25323 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g25323); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02653.java b/OWASP DATASET CLEANED/BenchmarkTest02653.java deleted file mode 100644 index 9f93aa1e9fdc5e0695459030a2711d8d7033c745..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02653.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02653") -public class BenchmarkTest02653 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02653" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02653" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02653" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - java.sql.ResultSet rs = statement.executeQuery(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02654.java b/OWASP DATASET CLEANED/BenchmarkTest02654.java deleted file mode 100644 index d977ceedd341b532f5b7b1794b3e6fd5aaeab9e2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02654.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02654") -public class BenchmarkTest02654 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02654" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02654" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02654" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02655.java b/OWASP DATASET CLEANED/BenchmarkTest02655.java deleted file mode 100644 index 86c4987b7cedd94cdf64bcbda4414d1f42ff2797..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02655.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02655") -public class BenchmarkTest02655 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02655" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02655" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02655" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02656.java b/OWASP DATASET CLEANED/BenchmarkTest02656.java deleted file mode 100644 index 301a160e55402bacb2961bc4c990a2a85f587bd4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02656.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02656") -public class BenchmarkTest02656 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02656" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02656" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02656" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02657.java b/OWASP DATASET CLEANED/BenchmarkTest02657.java deleted file mode 100644 index 66dc8b2b985a2ca5ec049f724718c9ba297d577d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02657.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02657") -public class BenchmarkTest02657 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - String queryString = request.getQueryString(); - String paramval = "BenchmarkTest02657" + "="; - int paramLoc = -1; - if (queryString != null) paramLoc = queryString.indexOf(paramval); - if (paramLoc == -1) { - response.getWriter() - .println( - "getQueryString() couldn't find expected parameter '" - + "BenchmarkTest02657" - + "' in query string."); - return; - } - - String param = - queryString.substring( - paramLoc - + paramval - .length()); // 1st assume "BenchmarkTest02657" param is last - // parameter in query string. - // And then check to see if its in the middle of the query string and if so, trim off what - // comes after. - int ampersandLoc = queryString.indexOf("&", paramLoc); - if (ampersandLoc != -1) { - param = queryString.substring(paramLoc + paramval.length(), ampersandLoc); - } - param = java.net.URLDecoder.decode(param, "UTF-8"); - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02658.java b/OWASP DATASET CLEANED/BenchmarkTest02658.java deleted file mode 100644 index 43e605f9e28f363d29bd7c29dc9b1fd16ddfedfb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02658.java +++ /dev/null @@ -1,162 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-03/BenchmarkTest02658") -public class BenchmarkTest02658 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02658"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println( - "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02659.java b/OWASP DATASET CLEANED/BenchmarkTest02659.java deleted file mode 100644 index 0f1e531ad2638e9548feaf4d80c6b07619bd84ce..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02659.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-03/BenchmarkTest02659") -public class BenchmarkTest02659 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02659"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // AES/GCM example from: - // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/ - // 16-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3, - // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9, - // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(16); - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - javax.crypto.spec.GCMParameterSpec paramSpec = - new javax.crypto.spec.GCMParameterSpec(16 * 8, iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.NoSuchPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.IllegalBlockSizeException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (javax.crypto.BadPaddingException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } catch (java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - response.getWriter() - .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02660.java b/OWASP DATASET CLEANED/BenchmarkTest02660.java deleted file mode 100644 index 7c7517460906015827e3337981fc36985c3c377a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02660.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-03/BenchmarkTest02660") -public class BenchmarkTest02660 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02660"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a97788 = param; // assign - StringBuilder b97788 = new StringBuilder(a97788); // stick in stringbuilder - b97788.append(" SafeStuff"); // append some safe content - b97788.replace( - b97788.length() - "Chars".length(), - b97788.length(), - "Chars"); // replace some of the end content - java.util.HashMap map97788 = new java.util.HashMap(); - map97788.put("key97788", b97788.toString()); // put in a collection - String c97788 = (String) map97788.get("key97788"); // get it back out - String d97788 = c97788.substring(0, c97788.length() - 1); // extract most of it - String e97788 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d97788.getBytes()))); // B64 encode and decode it - String f97788 = e97788.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f97788); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02661.java b/OWASP DATASET CLEANED/BenchmarkTest02661.java deleted file mode 100644 index d0f59a771983e91112cbfddfcb6be3dfd3a8d648..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02661.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-03/BenchmarkTest02661") -public class BenchmarkTest02661 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02661"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - // 8-byte initialization vector - // byte[] iv = { - // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2, - // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033 - // }; - java.security.SecureRandom random = new java.security.SecureRandom(); - byte[] iv = random.generateSeed(8); // DES requires 8 byte keys - - try { - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding"); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - java.security.spec.AlgorithmParameterSpec paramSpec = - new javax.crypto.spec.IvParameterSpec(iv); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException - | java.security.InvalidAlgorithmParameterException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02662.java b/OWASP DATASET CLEANED/BenchmarkTest02662.java deleted file mode 100644 index 231a3fff31eae5704f4735379cd82dd828826738..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02662.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-03/BenchmarkTest02662") -public class BenchmarkTest02662 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02662"); - - String bar = doSomething(request, param); - - // Code based on example from: - // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/ - - try { - javax.crypto.Cipher c = - javax.crypto.Cipher.getInstance( - "AES/CCM/NoPadding", java.security.Security.getProvider("BC")); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) bar = param.split(" ")[0]; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02663.java b/OWASP DATASET CLEANED/BenchmarkTest02663.java deleted file mode 100644 index 55e4c776850800670b8eabebc4f6349a70071999..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02663.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/crypto-03/BenchmarkTest02663") -public class BenchmarkTest02663 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02663"); - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding"); - javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm); - - // Prepare the cipher to encrypt - javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey(); - c.init(javax.crypto.Cipher.ENCRYPT_MODE, key); - - // encrypt and store the results - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - byte[] result = c.doFinal(input); - - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "secret_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' encrypted and stored
"); - - } catch (java.security.NoSuchAlgorithmException - | javax.crypto.NoSuchPaddingException - | javax.crypto.IllegalBlockSizeException - | javax.crypto.BadPaddingException - | java.security.InvalidKeyException e) { - response.getWriter() - .println( - "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"); - e.printStackTrace(response.getWriter()); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02664.java b/OWASP DATASET CLEANED/BenchmarkTest02664.java deleted file mode 100644 index ae604b3b96e66bfe2a1797fe36a84e998f4d2c03..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02664.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02664") -public class BenchmarkTest02664 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02664"); - - String bar = doSomething(request, param); - - java.io.File fileTarget = new java.io.File(bar, "/Test.txt"); - response.getWriter() - .println( - "Access to file: '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(fileTarget.toString()) - + "' created."); - if (fileTarget.exists()) { - response.getWriter().println(" And file already exists."); - } else { - response.getWriter().println(" But file doesn't exist yet."); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02665.java b/OWASP DATASET CLEANED/BenchmarkTest02665.java deleted file mode 100644 index d6c55f5ba671462dae83997dbf8351aa2c4a0182..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02665.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02665") -public class BenchmarkTest02665 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02665"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(new java.io.File(fileName)); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - response.getWriter() - .println( - "Problem getting FileInputStream: " - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(e.getMessage())); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02666.java b/OWASP DATASET CLEANED/BenchmarkTest02666.java deleted file mode 100644 index b4aa9af5df687b40e022740c4935a682bc8381b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02666.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02666") -public class BenchmarkTest02666 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02666"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02667.java b/OWASP DATASET CLEANED/BenchmarkTest02667.java deleted file mode 100644 index 5e6eb19daf96858ba529862eed26bd787862995e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02667.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02667") -public class BenchmarkTest02667 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02667"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileInputStream fis = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - fis = new java.io.FileInputStream(fileName); - byte[] b = new byte[1000]; - int size = fis.read(b); - response.getWriter() - .println( - "The beginning of file: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) - + "' is:\n\n"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size))); - } catch (Exception e) { - System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fis != null) { - try { - fis.close(); - fis = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02668.java b/OWASP DATASET CLEANED/BenchmarkTest02668.java deleted file mode 100644 index 82f322f0a0637a687a944c8ff7c4b04d78f6241f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02668.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02668") -public class BenchmarkTest02668 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02668"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName, false); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map94533 = new java.util.HashMap(); - map94533.put("keyA-94533", "a-Value"); // put some stuff in the collection - map94533.put("keyB-94533", param); // put it in a collection - map94533.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map94533.get("keyB-94533"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02669.java b/OWASP DATASET CLEANED/BenchmarkTest02669.java deleted file mode 100644 index babe6a4d1f22d6a351b7c4985a1eaaf694d3c2a3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02669.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/pathtraver-03/BenchmarkTest02669") -public class BenchmarkTest02669 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02669"); - - String bar = doSomething(request, param); - - String fileName = null; - java.io.FileOutputStream fos = null; - - try { - fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar; - - fos = new java.io.FileOutputStream(fileName); - response.getWriter() - .println( - "Now ready to write to file: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); - - } catch (Exception e) { - System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); - // System.out.println("File exception caught and swallowed: " + e.getMessage()); - } finally { - if (fos != null) { - try { - fos.close(); - fos = null; - } catch (Exception e) { - // we tried... - } - } - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02670.java b/OWASP DATASET CLEANED/BenchmarkTest02670.java deleted file mode 100644 index b0b3410a8f9becb80caea2bffd1667d12c4663d1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02670.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02670") -public class BenchmarkTest02670 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02670"); - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02671.java b/OWASP DATASET CLEANED/BenchmarkTest02671.java deleted file mode 100644 index f0a647c590fc92fc08dd960ff1281b762399b779..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02671.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02671") -public class BenchmarkTest02671 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02671"); - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("SHA1", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("SHA1", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map7984 = new java.util.HashMap(); - map7984.put("keyA-7984", "a-Value"); // put some stuff in the collection - map7984.put("keyB-7984", param); // put it in a collection - map7984.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map7984.get("keyB-7984"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02672.java b/OWASP DATASET CLEANED/BenchmarkTest02672.java deleted file mode 100644 index 9ba8f1f59000e920724104eb0df01c80687169db..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02672.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02672") -public class BenchmarkTest02672 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02672"); - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map48519 = new java.util.HashMap(); - map48519.put("keyA-48519", "a_Value"); // put some stuff in the collection - map48519.put("keyB-48519", param); // put it in a collection - map48519.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map48519.get("keyB-48519"); // get it back out - bar = (String) map48519.get("keyA-48519"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02673.java b/OWASP DATASET CLEANED/BenchmarkTest02673.java deleted file mode 100644 index 5e2a9d14f238d8f7e2e1f127e8ab3bcb3567f880..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02673.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02673") -public class BenchmarkTest02673 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02673"); - - String bar = doSomething(request, param); - - java.security.Provider[] provider = java.security.Security.getProviders(); - java.security.MessageDigest md; - - try { - if (provider.length > 1) { - - md = java.security.MessageDigest.getInstance("sha-384", provider[0]); - } else { - md = java.security.MessageDigest.getInstance("sha-384", "SUN"); - } - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } catch (java.security.NoSuchProviderException e) { - System.out.println( - "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz57216 = new StringBuilder(param); - bar = sbxyz57216.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02674.java b/OWASP DATASET CLEANED/BenchmarkTest02674.java deleted file mode 100644 index 2b53ff71dd46b453ce91f9053273a69fd8bd4328..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02674.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02674") -public class BenchmarkTest02674 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02674"); - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a73069 = param; // assign - StringBuilder b73069 = new StringBuilder(a73069); // stick in stringbuilder - b73069.append(" SafeStuff"); // append some safe content - b73069.replace( - b73069.length() - "Chars".length(), - b73069.length(), - "Chars"); // replace some of the end content - java.util.HashMap map73069 = new java.util.HashMap(); - map73069.put("key73069", b73069.toString()); // put in a collection - String c73069 = (String) map73069.get("key73069"); // get it back out - String d73069 = c73069.substring(0, c73069.length() - 1); // extract most of it - String e73069 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d73069.getBytes()))); // B64 encode and decode it - String f73069 = e73069.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g73069 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g73069); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02675.java b/OWASP DATASET CLEANED/BenchmarkTest02675.java deleted file mode 100644 index acae665f262a23641305f7b58b511a91e048d571..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02675.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02675") -public class BenchmarkTest02675 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02675"); - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02676.java b/OWASP DATASET CLEANED/BenchmarkTest02676.java deleted file mode 100644 index ea3a135bb74db00c09ef9f6a4666e96bcbaa5871..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02676.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02676") -public class BenchmarkTest02676 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02676"); - - String bar = doSomething(request, param); - - try { - java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256"); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02677.java b/OWASP DATASET CLEANED/BenchmarkTest02677.java deleted file mode 100644 index 4a03548e034bd834f3a77930bdce2b9faf5d8a7b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02677.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02677") -public class BenchmarkTest02677 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02677"); - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz68995 = new StringBuilder(param); - bar = sbxyz68995.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02678.java b/OWASP DATASET CLEANED/BenchmarkTest02678.java deleted file mode 100644 index 936d2d004920876fb88eb8f71319d248f121426b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02678.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/hash-02/BenchmarkTest02678") -public class BenchmarkTest02678 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02678"); - - String bar = doSomething(request, param); - - try { - java.util.Properties benchmarkprops = new java.util.Properties(); - benchmarkprops.load( - this.getClass().getClassLoader().getResourceAsStream("benchmark.properties")); - String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5"); - java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm); - byte[] input = {(byte) '?'}; - Object inputParam = bar; - if (inputParam instanceof String) input = ((String) inputParam).getBytes(); - if (inputParam instanceof java.io.InputStream) { - byte[] strInput = new byte[1000]; - int i = ((java.io.InputStream) inputParam).read(strInput); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - input = java.util.Arrays.copyOf(strInput, i); - } - md.update(input); - - byte[] result = md.digest(); - java.io.File fileTarget = - new java.io.File( - new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), - "passwordFile.txt"); - java.io.FileWriter fw = - new java.io.FileWriter(fileTarget, true); // the true will append the new data - fw.write( - "hash_value=" - + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) - + "\n"); - fw.close(); - response.getWriter() - .println( - "Sensitive value '" - + org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(new String(input)) - + "' hashed and stored
"); - - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing hash - TestCase"); - throw new ServletException(e); - } - - response.getWriter() - .println( - "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02679.java b/OWASP DATASET CLEANED/BenchmarkTest02679.java deleted file mode 100644 index 62ad5b089fe221640eb61d8ab7a3f60fb299a66a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02679.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02679") -public class BenchmarkTest02679 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02679"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - java.io.PrintWriter out = response.getWriter(); - out.write("\n\n\n

"); - out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - out.write("\n

\n\n"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02680.java b/OWASP DATASET CLEANED/BenchmarkTest02680.java deleted file mode 100644 index 012069c8869d2abf6c880e2b9928316d56ddf055..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02680.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02680") -public class BenchmarkTest02680 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02680"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02681.java b/OWASP DATASET CLEANED/BenchmarkTest02681.java deleted file mode 100644 index 59f80cb8f55c84dafdc2cd95d2ffd514081b66e7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02681.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02681") -public class BenchmarkTest02681 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02681"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().format(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02682.java b/OWASP DATASET CLEANED/BenchmarkTest02682.java deleted file mode 100644 index 32927a22f40d8acbf5aac34c60021c86bf2294d3..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02682.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02682") -public class BenchmarkTest02682 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02682"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02683.java b/OWASP DATASET CLEANED/BenchmarkTest02683.java deleted file mode 100644 index cd34b81f86565eb478eca426b99d574e42efa096..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02683.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02683") -public class BenchmarkTest02683 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02683"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a47309 = param; // assign - StringBuilder b47309 = new StringBuilder(a47309); // stick in stringbuilder - b47309.append(" SafeStuff"); // append some safe content - b47309.replace( - b47309.length() - "Chars".length(), - b47309.length(), - "Chars"); // replace some of the end content - java.util.HashMap map47309 = new java.util.HashMap(); - map47309.put("key47309", b47309.toString()); // put in a collection - String c47309 = (String) map47309.get("key47309"); // get it back out - String d47309 = c47309.substring(0, c47309.length() - 1); // extract most of it - String e47309 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d47309.getBytes()))); // B64 encode and decode it - String f47309 = e47309.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g47309 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g47309); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02684.java b/OWASP DATASET CLEANED/BenchmarkTest02684.java deleted file mode 100644 index d5fe38151ec95465433b5aa75ac3d4eb99a191cb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02684.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02684") -public class BenchmarkTest02684 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02684"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().print(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02685.java b/OWASP DATASET CLEANED/BenchmarkTest02685.java deleted file mode 100644 index 2eec2ae985cd253b3392c4854533b64cc589cec4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02685.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02685") -public class BenchmarkTest02685 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02685"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", bar}; - response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02686.java b/OWASP DATASET CLEANED/BenchmarkTest02686.java deleted file mode 100644 index a087e2a3b4f3c249a0c1625ca5cced5dff399587..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02686.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02686") -public class BenchmarkTest02686 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02686"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map36618 = new java.util.HashMap(); - map36618.put("keyA-36618", "a_Value"); // put some stuff in the collection - map36618.put("keyB-36618", param); // put it in a collection - map36618.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map36618.get("keyB-36618"); // get it back out - bar = (String) map36618.get("keyA-36618"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02687.java b/OWASP DATASET CLEANED/BenchmarkTest02687.java deleted file mode 100644 index e1f139b3a84cbfc77eb6e8252487fc3a38f175f6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02687.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02687") -public class BenchmarkTest02687 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02687"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(java.util.Locale.US, bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02688.java b/OWASP DATASET CLEANED/BenchmarkTest02688.java deleted file mode 100644 index b006d21ba3a0b273a634060a9d4f6725883d8e61..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02688.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02688") -public class BenchmarkTest02688 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02688"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02689.java b/OWASP DATASET CLEANED/BenchmarkTest02689.java deleted file mode 100644 index ece55bb5aa56956d3045c0bd33f08ddb7fa40441..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02689.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02689") -public class BenchmarkTest02689 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02689"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02690.java b/OWASP DATASET CLEANED/BenchmarkTest02690.java deleted file mode 100644 index bd138d7cdeed616d1c79b6e39caac50a2ce0a697..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02690.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02690") -public class BenchmarkTest02690 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02690"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - Object[] obj = {"a", "b"}; - response.getWriter().printf(bar, obj); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02691.java b/OWASP DATASET CLEANED/BenchmarkTest02691.java deleted file mode 100644 index 67a32da60b2df31dcd39dcc9425dd91bc2591ace..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02691.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02691") -public class BenchmarkTest02691 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02691"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02692.java b/OWASP DATASET CLEANED/BenchmarkTest02692.java deleted file mode 100644 index 8de38e6e6c11da9001bf314d573651625cdb2c0b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02692.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02692") -public class BenchmarkTest02692 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02692"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02693.java b/OWASP DATASET CLEANED/BenchmarkTest02693.java deleted file mode 100644 index 0d963d3e33c9deb7ab9abce27882fe0b1e9a1785..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02693.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02693") -public class BenchmarkTest02693 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02693"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz14220 = new StringBuilder(param); - bar = sbxyz14220.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02694.java b/OWASP DATASET CLEANED/BenchmarkTest02694.java deleted file mode 100644 index c880a39ce6c1e2c4a67ccde3a5a16d2be88d8ad0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02694.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02694") -public class BenchmarkTest02694 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02694"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().println(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02695.java b/OWASP DATASET CLEANED/BenchmarkTest02695.java deleted file mode 100644 index 3df3df118c42df9c9b2f92ae79523756f16e1382..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02695.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02695") -public class BenchmarkTest02695 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02695"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar.toCharArray()); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02696.java b/OWASP DATASET CLEANED/BenchmarkTest02696.java deleted file mode 100644 index 70558684e856d45c4ba5770d08df8aaa0ed1a73a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02696.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02696") -public class BenchmarkTest02696 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02696"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write(bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02697.java b/OWASP DATASET CLEANED/BenchmarkTest02697.java deleted file mode 100644 index d13e5b421322a186d234a41399a23d80b28a9a1d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02697.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02697") -public class BenchmarkTest02697 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02697"); - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map29916 = new java.util.HashMap(); - map29916.put("keyA-29916", "a-Value"); // put some stuff in the collection - map29916.put("keyB-29916", param); // put it in a collection - map29916.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map29916.get("keyB-29916"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02698.java b/OWASP DATASET CLEANED/BenchmarkTest02698.java deleted file mode 100644 index 26e7de5601af437b8e3a0eba0ed2bf7dbf77e8f1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02698.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02698") -public class BenchmarkTest02698 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02698"); - - String bar = doSomething(request, param); - - java.util.List argList = new java.util.ArrayList(); - - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - argList.add("cmd.exe"); - argList.add("/c"); - } else { - argList.add("sh"); - argList.add("-c"); - } - argList.add("echo " + bar); - - ProcessBuilder pb = new ProcessBuilder(); - - pb.command(argList); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.util.List) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02699.java b/OWASP DATASET CLEANED/BenchmarkTest02699.java deleted file mode 100644 index 095d56ccc0abe5e2db723cfcc80f831d87dd3b01..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02699.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02699") -public class BenchmarkTest02699 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02699"); - - String bar = doSomething(request, param); - - String a1 = ""; - String a2 = ""; - String osName = System.getProperty("os.name"); - if (osName.indexOf("Windows") != -1) { - a1 = "cmd.exe"; - a2 = "/c"; - } else { - a1 = "sh"; - a2 = "-c"; - } - String[] args = {a1, a2, "echo " + bar}; - - ProcessBuilder pb = new ProcessBuilder(args); - - try { - Process p = pb.start(); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println( - "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case"); - throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02700.java b/OWASP DATASET CLEANED/BenchmarkTest02700.java deleted file mode 100644 index 49607494676355559b5575ba9f44dfd58811a5b7..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02700.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02700") -public class BenchmarkTest02700 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02700"); - - String bar = doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02701.java b/OWASP DATASET CLEANED/BenchmarkTest02701.java deleted file mode 100644 index d14a928190d4366dc655e3c60176e25030576919..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02701.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02701") -public class BenchmarkTest02701 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02701"); - - String bar = doSomething(request, param); - - byte[] bytes = new byte[10]; - new java.util.Random().nextBytes(bytes); - String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true); - - String user = "Byron"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz86795 = new StringBuilder(param); - String bar = sbxyz86795.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02702.java b/OWASP DATASET CLEANED/BenchmarkTest02702.java deleted file mode 100644 index 307f17905ac67fec0516f4aa154188b46871c229..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02702.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-05/BenchmarkTest02702") -public class BenchmarkTest02702 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02702"); - - String bar = doSomething(request, param); - - double value = new java.util.Random().nextDouble(); - String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front. - - String user = "Donna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02703.java b/OWASP DATASET CLEANED/BenchmarkTest02703.java deleted file mode 100644 index 7276ec11ac3a1d5deff23213628c1d0bfe8638a8..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02703.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02703") -public class BenchmarkTest02703 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02703"); - - String bar = doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz50196 = new StringBuilder(param); - String bar = sbxyz50196.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02704.java b/OWASP DATASET CLEANED/BenchmarkTest02704.java deleted file mode 100644 index ddf3192cfb18d5cd9c2268885a719670166a3ad2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02704.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02704") -public class BenchmarkTest02704 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02704"); - - String bar = doSomething(request, param); - - float rand = new java.util.Random().nextFloat(); - String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "Floyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz82472 = new StringBuilder(param); - bar = sbxyz82472.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02705.java b/OWASP DATASET CLEANED/BenchmarkTest02705.java deleted file mode 100644 index dab01d0ae758eecda25257b8777c78bc18c8df13..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02705.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02705") -public class BenchmarkTest02705 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02705"); - - String bar = doSomething(request, param); - - double stuff = new java.util.Random().nextGaussian(); - String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "Gayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter() - .println("Weak Randomness Test java.util.Random.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - StringBuilder sbxyz10228 = new StringBuilder(param); - bar = sbxyz10228.replace(param.length() - "Z".length(), param.length(), "Z").toString(); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02706.java b/OWASP DATASET CLEANED/BenchmarkTest02706.java deleted file mode 100644 index fa3393bd8a839e80794a7ac3f0460c61eeb9da1d..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02706.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02706") -public class BenchmarkTest02706 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02706"); - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - bar = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - param.getBytes()))); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02707.java b/OWASP DATASET CLEANED/BenchmarkTest02707.java deleted file mode 100644 index 16ac6c47ed97d9094cbff8a6cfb45554abbfc56b..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02707.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02707") -public class BenchmarkTest02707 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02707"); - - String bar = doSomething(request, param); - - int r = new java.util.Random().nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "Ingrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02708.java b/OWASP DATASET CLEANED/BenchmarkTest02708.java deleted file mode 100644 index 065a9bf63a3b9b381e7f312a0c59b45beb8efaed..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02708.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02708") -public class BenchmarkTest02708 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02708"); - - String bar = doSomething(request, param); - - long l = new java.util.Random().nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "Logan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - - response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02709.java b/OWASP DATASET CLEANED/BenchmarkTest02709.java deleted file mode 100644 index 47ed1b211d02d25561b119eb485d97a077830f0e..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02709.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02709") -public class BenchmarkTest02709 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02709"); - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns param to bar on false condition - int num = 106; - - bar = (7 * 42) - num > 200 ? "This should never happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02710.java b/OWASP DATASET CLEANED/BenchmarkTest02710.java deleted file mode 100644 index 5abefcf1d9e2e866015af52cc2c5abc293367211..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02710.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02710") -public class BenchmarkTest02710 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02710"); - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(false); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: false"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02711.java b/OWASP DATASET CLEANED/BenchmarkTest02711.java deleted file mode 100644 index c9712619b289c59b6b3011e0e4f46de9a90014b5..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02711.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/securecookie-00/BenchmarkTest02711") -public class BenchmarkTest02711 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02711"); - - String bar = doSomething(request, param); - - byte[] input = new byte[1000]; - String str = "?"; - Object inputParam = param; - if (inputParam instanceof String) str = ((String) inputParam); - if (inputParam instanceof java.io.InputStream) { - int i = ((java.io.InputStream) inputParam).read(input); - if (i == -1) { - response.getWriter() - .println( - "This input source requires a POST, not a GET. Incompatible UI for the InputStream source."); - return; - } - str = new String(input, 0, i); - } - if ("".equals(str)) str = "No cookie value supplied"; - javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str); - - cookie.setSecure(true); - cookie.setHttpOnly(true); - cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - response.addCookie(cookie); - - response.getWriter() - .println( - "Created cookie: 'SomeCookie': with value: '" - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str) - + "' and secure flag set to: true"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02712.java b/OWASP DATASET CLEANED/BenchmarkTest02712.java deleted file mode 100644 index 8e75f55fe3b2e981e5e95754142ca8ea532158af..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02712.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/xss-05/BenchmarkTest02712") -public class BenchmarkTest02712 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02712"); - - String bar = doSomething(request, param); - - response.setHeader("X-XSS-Protection", "0"); - response.getWriter().write("Parameter value: " + bar); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map52216 = new java.util.HashMap(); - map52216.put("keyA-52216", "a_Value"); // put some stuff in the collection - map52216.put("keyB-52216", param); // put it in a collection - map52216.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map52216.get("keyB-52216"); // get it back out - bar = (String) map52216.get("keyA-52216"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02713.java b/OWASP DATASET CLEANED/BenchmarkTest02713.java deleted file mode 100644 index d6a9cf8b45c24767e2fc665b24943cddcfe65372..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02713.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02713") -public class BenchmarkTest02713 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02713"); - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] args = {cmd}; - String[] argsEnv = {bar}; - - Runtime r = Runtime.getRuntime(); - - try { - Process p = r.exec(args, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02714.java b/OWASP DATASET CLEANED/BenchmarkTest02714.java deleted file mode 100644 index 6f38a98e7335c2f08135829c33c25276a67e0acb..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02714.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/cmdi-03/BenchmarkTest02714") -public class BenchmarkTest02714 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02714"); - - String bar = doSomething(request, param); - - String cmd = - org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString( - this.getClass().getClassLoader()); - String[] argsEnv = {bar}; - Runtime r = Runtime.getRuntime(); - try { - Process p = r.exec(cmd, argsEnv, new java.io.File(System.getProperty("user.dir"))); - org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response); - } catch (IOException e) { - System.out.println("Problem executing cmdi - TestCase"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())); - return; - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02715.java b/OWASP DATASET CLEANED/BenchmarkTest02715.java deleted file mode 100644 index c8988a5a22ef200cd1a11ed0472b15942f919717..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02715.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02715") -public class BenchmarkTest02715 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02715"); - - String bar = doSomething(request, param); - - try { - double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble(); - - String rememberMeKey = - Double.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeDonna"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextDouble() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02716.java b/OWASP DATASET CLEANED/BenchmarkTest02716.java deleted file mode 100644 index 45e0a535425eb13972be53bd4145e053c13eaa05..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02716.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02716") -public class BenchmarkTest02716 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02716"); - - String bar = doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a26751 = param; // assign - StringBuilder b26751 = new StringBuilder(a26751); // stick in stringbuilder - b26751.append(" SafeStuff"); // append some safe content - b26751.replace( - b26751.length() - "Chars".length(), - b26751.length(), - "Chars"); // replace some of the end content - java.util.HashMap map26751 = new java.util.HashMap(); - map26751.put("key26751", b26751.toString()); // put in a collection - String c26751 = (String) map26751.get("key26751"); // get it back out - String d26751 = c26751.substring(0, c26751.length() - 1); // extract most of it - String e26751 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d26751.getBytes()))); // B64 encode and decode it - String f26751 = e26751.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g26751 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g26751); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02717.java b/OWASP DATASET CLEANED/BenchmarkTest02717.java deleted file mode 100644 index 767d1e84fa14692be5edff718937e9b4a207c023..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02717.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02717") -public class BenchmarkTest02717 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02717"); - - String bar = doSomething(request, param); - - try { - float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); - String rememberMeKey = - Float.toString(rand).substring(2); // Trim off the 0. at the front. - - String user = "SafeFloyd"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02718.java b/OWASP DATASET CLEANED/BenchmarkTest02718.java deleted file mode 100644 index 7e3a8f1056ded2ee8735c50f68c215de51ce024a..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02718.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02718") -public class BenchmarkTest02718 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02718"); - - String bar = doSomething(request, param); - - try { - double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian(); - String rememberMeKey = - Double.toString(stuff).substring(2); // Trim off the 0. at the front. - - String user = "SafeGayle"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a49179 = param; // assign - StringBuilder b49179 = new StringBuilder(a49179); // stick in stringbuilder - b49179.append(" SafeStuff"); // append some safe content - b49179.replace( - b49179.length() - "Chars".length(), - b49179.length(), - "Chars"); // replace some of the end content - java.util.HashMap map49179 = new java.util.HashMap(); - map49179.put("key49179", b49179.toString()); // put in a collection - String c49179 = (String) map49179.get("key49179"); // get it back out - String d49179 = c49179.substring(0, c49179.length() - 1); // extract most of it - String e49179 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d49179.getBytes()))); // B64 encode and decode it - String f49179 = e49179.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(f49179); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02719.java b/OWASP DATASET CLEANED/BenchmarkTest02719.java deleted file mode 100644 index ff4babe3c68eaf908b78575616ce8e43f1a9ef22..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02719.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02719") -public class BenchmarkTest02719 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02719"); - - String bar = doSomething(request, param); - - try { - int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(); - String rememberMeKey = Integer.toString(r); - - String user = "SafeIngrid"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextInt() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map75503 = new java.util.HashMap(); - map75503.put("keyA-75503", "a_Value"); // put some stuff in the collection - map75503.put("keyB-75503", param); // put it in a collection - map75503.put("keyC", "another_Value"); // put some stuff in the collection - bar = (String) map75503.get("keyB-75503"); // get it back out - bar = (String) map75503.get("keyA-75503"); // get safe value back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02720.java b/OWASP DATASET CLEANED/BenchmarkTest02720.java deleted file mode 100644 index 0a0a5060efadbd6fb488b47e905865b2e8004f4c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02720.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02720") -public class BenchmarkTest02720 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02720"); - - String bar = doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02721.java b/OWASP DATASET CLEANED/BenchmarkTest02721.java deleted file mode 100644 index 31d4b4a75de9e9a676beeb814a6f6c5919b01224..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02721.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/weakrand-06/BenchmarkTest02721") -public class BenchmarkTest02721 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02721"); - - String bar = doSomething(request, param); - - try { - long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong(); - String rememberMeKey = Long.toString(l); - - String user = "SafeLogan"; - String fullClassName = this.getClass().getName(); - String testCaseNumber = - fullClassName.substring( - fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length()); - user += testCaseNumber; - - String cookieName = "rememberMe" + testCaseNumber; - - boolean foundUser = false; - javax.servlet.http.Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; !foundUser && i < cookies.length; i++) { - javax.servlet.http.Cookie cookie = cookies[i]; - if (cookieName.equals(cookie.getName())) { - if (cookie.getValue() - .equals(request.getSession().getAttribute(cookieName))) { - foundUser = true; - } - } - } - } - - if (foundUser) { - response.getWriter().println("Welcome back: " + user + "
"); - } else { - javax.servlet.http.Cookie rememberMe = - new javax.servlet.http.Cookie(cookieName, rememberMeKey); - rememberMe.setSecure(true); - rememberMe.setHttpOnly(true); - rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet - // e.g., /benchmark/sql-01/BenchmarkTest01001 - request.getSession().setAttribute(cookieName, rememberMeKey); - response.addCookie(rememberMe); - response.getWriter() - .println( - user - + " has been remembered with cookie: " - + rememberMe.getName() - + " whose value is: " - + rememberMe.getValue() - + "
"); - } - } catch (java.security.NoSuchAlgorithmException e) { - System.out.println("Problem executing SecureRandom.nextLong() - TestCase"); - throw new ServletException(e); - } - response.getWriter() - .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed"); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02722.java b/OWASP DATASET CLEANED/BenchmarkTest02722.java deleted file mode 100644 index cc495fa10d2f724da30652227d5eec0454172e03..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02722.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02722") -public class BenchmarkTest02722 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02722"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02723.java b/OWASP DATASET CLEANED/BenchmarkTest02723.java deleted file mode 100644 index 5de5f75f1985e5077a45bc139617776ee2a32539..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02723.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02723") -public class BenchmarkTest02723 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02723"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - StringBuilder sbxyz51151 = new StringBuilder(param); - String bar = sbxyz51151.append("_SafeStuff").toString(); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02724.java b/OWASP DATASET CLEANED/BenchmarkTest02724.java deleted file mode 100644 index e48d0d8a09ec45b8bb90b48330485ba3a197f5ef..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02724.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02724") -public class BenchmarkTest02724 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02724"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object) - request.getSession().putValue(bar, "10340"); - - response.getWriter() - .println( - "Item: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' with value: 10340 saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(2); - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bobs_your_uncle"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bobs_your_uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02725.java b/OWASP DATASET CLEANED/BenchmarkTest02725.java deleted file mode 100644 index 1debd0a01421506a34f964ad256dbc3f71d37f9f..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02725.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02725") -public class BenchmarkTest02725 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02725"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple ? condition that assigns constant to bar on true condition - int num = 106; - - bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02726.java b/OWASP DATASET CLEANED/BenchmarkTest02726.java deleted file mode 100644 index 88cc65a0779fe668bf97360d5ce38cadd81004a1..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02726.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/trustbound-01/BenchmarkTest02726") -public class BenchmarkTest02726 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02726"); - - String bar = doSomething(request, param); - - // javax.servlet.http.HttpSession.setAttribute(java.lang.String,java.lang.Object^) - request.getSession().setAttribute("userid", bar); - - response.getWriter() - .println( - "Item: 'userid' with value: '" - + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar) - + "' saved in session."); - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - if (param != null && param.length() > 1) { - bar = param.substring(0, param.length() - 1); - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02727.java b/OWASP DATASET CLEANED/BenchmarkTest02727.java deleted file mode 100644 index aec1ee5ed66f2dbada47f09c638ba2ef89757c51..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02727.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02727") -public class BenchmarkTest02727 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02727"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02728.java b/OWASP DATASET CLEANED/BenchmarkTest02728.java deleted file mode 100644 index c321da721ed3574ca337017166a1191fec5bc4b6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02728.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02728") -public class BenchmarkTest02728 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02728"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement( - sql, - java.sql.ResultSet.TYPE_FORWARD_ONLY, - java.sql.ResultSet.CONCUR_READ_ONLY, - java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map55235 = new java.util.HashMap(); - map55235.put("keyA-55235", "a-Value"); // put some stuff in the collection - map55235.put("keyB-55235", param); // put it in a collection - map55235.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map55235.get("keyB-55235"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02729.java b/OWASP DATASET CLEANED/BenchmarkTest02729.java deleted file mode 100644 index 181c4a4a309440bb41b530eeac70abab84958e31..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02729.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02729") -public class BenchmarkTest02729 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02729"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new int[] {1, 2}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "safe!"; - java.util.HashMap map87005 = new java.util.HashMap(); - map87005.put("keyA-87005", "a-Value"); // put some stuff in the collection - map87005.put("keyB-87005", param); // put it in a collection - map87005.put("keyC", "another-Value"); // put some stuff in the collection - bar = (String) map87005.get("keyB-87005"); // get it back out - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02730.java b/OWASP DATASET CLEANED/BenchmarkTest02730.java deleted file mode 100644 index 612f69b00bfb0c6a7c1af48acf8960029d2deefc..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02730.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02730") -public class BenchmarkTest02730 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02730"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'"; - - try { - java.sql.Connection connection = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); - java.sql.PreparedStatement statement = - connection.prepareStatement(sql, new String[] {"Column1", "Column2"}); - statement.setString(1, "foo"); - statement.execute(); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - // Chain a bunch of propagators in sequence - String a81593 = param; // assign - StringBuilder b81593 = new StringBuilder(a81593); // stick in stringbuilder - b81593.append(" SafeStuff"); // append some safe content - b81593.replace( - b81593.length() - "Chars".length(), - b81593.length(), - "Chars"); // replace some of the end content - java.util.HashMap map81593 = new java.util.HashMap(); - map81593.put("key81593", b81593.toString()); // put in a collection - String c81593 = (String) map81593.get("key81593"); // get it back out - String d81593 = c81593.substring(0, c81593.length() - 1); // extract most of it - String e81593 = - new String( - org.apache.commons.codec.binary.Base64.decodeBase64( - org.apache.commons.codec.binary.Base64.encodeBase64( - d81593.getBytes()))); // B64 encode and decode it - String f81593 = e81593.split(" ")[0]; // split it on a space - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String g81593 = "barbarians_at_the_gate"; // This is static so this whole flow is 'safe' - String bar = thing.doSomething(g81593); // reflection - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02731.java b/OWASP DATASET CLEANED/BenchmarkTest02731.java deleted file mode 100644 index f30d8bba399646cd3fb85f99d78292ee0a311cab..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02731.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02731") -public class BenchmarkTest02731 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02731"); - - String bar = doSomething(request, param); - - try { - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql); - response.getWriter() - .println( - "No results can be displayed for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql) - + "
" - + " because the Spring batchUpdate method doesn't return results."); - // System.out.println("no results for query: " + sql + " because the Spring batchUpdate - // method doesn't return results."); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02732.java b/OWASP DATASET CLEANED/BenchmarkTest02732.java deleted file mode 100644 index c81f37e173256a97e774679d378b815be92846f0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02732.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02732") -public class BenchmarkTest02732 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02732"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query( - sql, - new org.springframework.jdbc.core.RowMapper() { - @Override - public String mapRow(java.sql.ResultSet rs, int rowNum) - throws java.sql.SQLException { - try { - return rs.getString("USERNAME"); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper - .hideSQLErrors) { - return "Error processing query."; - } else throw e; - } - } - }); - response.getWriter().println("Your results are: "); - - for (String s : results) { - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "
"); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02733.java b/OWASP DATASET CLEANED/BenchmarkTest02733.java deleted file mode 100644 index c46610b1447b52388b5e0fdd4e65db51ca6c1bd6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02733.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02733") -public class BenchmarkTest02733 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02733"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.List> list = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForList(sql); - response.getWriter().println("Your results are:
"); - - // System.out.println("Your results are"); - - for (Object o : list) { - response.getWriter() - .println( - org.owasp.esapi.ESAPI.encoder().encodeForHTML(o.toString()) - + "
"); - // System.out.println(o.toString()); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02734.java b/OWASP DATASET CLEANED/BenchmarkTest02734.java deleted file mode 100644 index 792e7a88383033bbe3d91c21a272c1812991a621..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02734.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02734") -public class BenchmarkTest02734 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02734"); - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02735.java b/OWASP DATASET CLEANED/BenchmarkTest02735.java deleted file mode 100644 index 2452dab95712181522999aa9dca7d3a407cc92b4..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02735.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02735") -public class BenchmarkTest02735 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02735"); - - String bar = doSomething(request, param); - - String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - // Long results = - // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql); - Long results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject( - sql, Long.class); - response.getWriter().println("Your results are: " + String.valueOf(results)); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - String guess = "ABC"; - char switchTarget = guess.charAt(1); // condition 'B', which is safe - - // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D' - switch (switchTarget) { - case 'A': - bar = param; - break; - case 'B': - bar = "bob"; - break; - case 'C': - case 'D': - bar = param; - break; - default: - bar = "bob's your uncle"; - break; - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02736.java b/OWASP DATASET CLEANED/BenchmarkTest02736.java deleted file mode 100644 index 88f3add43e74fd7f990955d42543c8859bfae7d6..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02736.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02736") -public class BenchmarkTest02736 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02736"); - - String bar = doSomething(request, param); - - String sql = - "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - java.util.Map results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForMap(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - response.getWriter() - .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString())); - // System.out.println(results.toString()); - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - org.owasp.benchmark.helpers.ThingInterface thing = - org.owasp.benchmark.helpers.ThingFactory.createThing(); - String bar = thing.doSomething(param); - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02737.java b/OWASP DATASET CLEANED/BenchmarkTest02737.java deleted file mode 100644 index 132861fb46ac3b7bdfc94978eb6358e9b4bea56c..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02737.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02737") -public class BenchmarkTest02737 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02737"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - try { - org.springframework.jdbc.support.rowset.SqlRowSet results = - org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql); - response.getWriter().println("Your results are: "); - - // System.out.println("Your results are"); - while (results.next()) { - response.getWriter() - .println( - org.owasp - .esapi - .ESAPI - .encoder() - .encodeForHTML(results.getString("USERNAME")) - + " "); - // System.out.println(results.getString("USERNAME")); - } - } catch (org.springframework.dao.EmptyResultDataAccessException e) { - response.getWriter() - .println( - "No results returned for query: " - + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)); - } catch (org.springframework.dao.DataAccessException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns constant to bar on true condition - int num = 86; - if ((7 * 42) - num > 200) bar = "This_should_always_happen"; - else bar = param; - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02738.java b/OWASP DATASET CLEANED/BenchmarkTest02738.java deleted file mode 100644 index 7fb69c2e4b0d3dcc7e755b479d70104efd7cdfc2..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02738.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02738") -public class BenchmarkTest02738 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02738"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = "alsosafe"; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(1); // get the last 'safe' value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02739.java b/OWASP DATASET CLEANED/BenchmarkTest02739.java deleted file mode 100644 index 3c57c2e53468f8181cf8e49ab7fa59052ae421f0..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02739.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02739") -public class BenchmarkTest02739 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02739"); - - String bar = doSomething(request, param); - - String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - statement.execute(sql, new int[] {1, 2}); - org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar = ""; - if (param != null) { - java.util.List valuesList = new java.util.ArrayList(); - valuesList.add("safe"); - valuesList.add(param); - valuesList.add("moresafe"); - - valuesList.remove(0); // remove the 1st safe value - - bar = valuesList.get(0); // get the param value - } - - return bar; - } -} diff --git a/OWASP DATASET CLEANED/BenchmarkTest02740.java b/OWASP DATASET CLEANED/BenchmarkTest02740.java deleted file mode 100644 index b573cfc1561b1bfb7db84a0537f7d1494a959461..0000000000000000000000000000000000000000 --- a/OWASP DATASET CLEANED/BenchmarkTest02740.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * OWASP Benchmark Project v1.2 - * - *

This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For - * details, please see https://owasp.org/www-project-benchmark/. - * - *

The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, version 2. - * - *

The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * @author Nick Sanidas - * @created 2015 - */ -package org.owasp.benchmark.testcode; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(value = "/sqli-06/BenchmarkTest02740") -public class BenchmarkTest02740 extends HttpServlet { - - private static final long serialVersionUID = 1L; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - - org.owasp.benchmark.helpers.SeparateClassRequest scr = - new org.owasp.benchmark.helpers.SeparateClassRequest(request); - String param = scr.getTheValue("BenchmarkTest02740"); - - String bar = doSomething(request, param); - - String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')"; - - try { - java.sql.Statement statement = - org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement(); - int count = statement.executeUpdate(sql); - org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response); - } catch (java.sql.SQLException e) { - if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) { - response.getWriter().println("Error processing request."); - return; - } else throw new ServletException(e); - } - } // end doPost - - private static String doSomething(HttpServletRequest request, String param) - throws ServletException, IOException { - - String bar; - - // Simple if statement that assigns param to bar on true condition - int num = 196; - if ((500 / 42) + num > 200) bar = param; - else bar = "This should never happen"; - - return bar; - } -}